Repository: joke2k/faker
Pull request #1639 (2022-04-27 05:09:25)

Add vi-VN automotive provider
Added automotive provider for vi-VN locale.


Patch:
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index f63abff9..f90cdd16 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 13.5.0
+current_version = 13.6.0
 files = VERSION faker/__init__.py docs/conf.py
 commit = True
 tag = True
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77cf55b6..5848d54d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,12 @@
 ## Changelog
 
+### [v13.6.0 - 2022-04-27](https://github.com/joke2k/faker/compare/v13.5.0...v13.6.0)
+
+* Add `ar_BH` automotive provider. Thanks @zerogonal.
+
 ### [v13.5.0 - 2022-04-27](https://github.com/joke2k/faker/compare/v13.4.0...v13.5.0)
 
-* Add mexican CLABE bank code for `es_MX` locale. Thanks @edgarrmondragon.
+* Add Mexican CLABE bank code for `es_MX` locale. Thanks @edgarrmondragon.
 
 ### [v13.4.0 - 2022-04-22](https://github.com/joke2k/faker/compare/v13.3.5...v13.4.0)
 
diff --git a/VERSION b/VERSION
index d224e690..fc9c00c1 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-13.5.0
+13.6.0
diff --git a/docs/conf.py b/docs/conf.py
index 3276292c..4beadaee 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -51,9 +51,9 @@ copyright = "2014, Daniele Faraglia"
 # built documents.
 #
 # The short X.Y version.
-version = "13.5.0"
+version = "13.6.0"
 # The full version, including alpha/beta/rc tags.
-release = "13.5.0"
+release = "13.6.0"
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/faker/__init__.py b/faker/__init__.py
index dd9f40ca..3d24ad36 100644
--- a/faker/__init__.py
+++ b/faker/__init__.py
@@ -2,6 +2,6 @@ from faker.factory import Factory
 from faker.generator import Generator
 from faker.proxy import Faker
 
-VERSION = "13.5.0"
+VERSION = "13.6.0"
 
 __all__ = ("Factory", "Generator", "Faker")
diff --git a/faker/providers/automotive/vi_VN/__init__.py b/faker/providers/automotive/vi_VN/__init__.py
new file mode 100644
index 00000000..f877249a
--- /dev/null
+++ b/faker/providers/automotive/vi_VN/__init__.py
@@ -0,0 +1,24 @@
+import re
+
+from .. import Provider as AutomotiveProvider
+
+
+class Provider(AutomotiveProvider):
+    """Implement automotive provider for ``vi_VN`` locale.
+
+    Sources:
+
+    - https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Vietnam
+    """
+
+    license_formats = ("##?-#####",)
+    ascii_uppercase_vietnamese = "ABCDĐEFGHKLMNPSTUVXYZ"
+
+    def license_plate(self) -> str:
+        """Generate a license plate."""
+        temp = re.sub(
+            r"\?",
+            lambda x: self.random_element(self.ascii_uppercase_vietnamese),
+            self.random_element(self.license_formats),
+        )
+        return self.numerify(temp)


Test patch:
diff --git a/tests/providers/test_automotive.py b/tests/providers/test_automotive.py
index 98a9e006..3097a674 100644
--- a/tests/providers/test_automotive.py
+++ b/tests/providers/test_automotive.py
@@ -20,10 +20,16 @@ class _SimpleAutomotiveTestMixin:
         for _ in range(num_samples):
             license_plate = faker.license_plate()
             match = self.license_plate_pattern.fullmatch(license_plate)
-            assert match
+            assert match is not None
             self.perform_extra_checks(license_plate, match)
 
 
+class TestArBh(_SimpleAutomotiveTestMixin):
+    """Test ar_BH automotive provider methods"""
+
+    license_plate_pattern: Pattern = re.compile(r"\d{6}")
+
+
 class TestAzAz(_SimpleAutomotiveTestMixin):
     """Test az_AZ automotive provider methods"""
 
@@ -282,7 +288,7 @@ class TestNlNl(_SimpleAutomotiveTestMixin):
             assert self.license_plate_motorbike_pattern.match(plate)
 
 
-class TestArBh(_SimpleAutomotiveTestMixin):
-    """Test ar_BH automotive provider methods"""
+class TestViVn(_SimpleAutomotiveTestMixin):
+    """Test vi_VN automotive provider methods"""
 
-    license_plate_pattern: Pattern = re.compile(r"\d{6}")
+    license_plate_pattern: Pattern = re.compile(r"\d{2}[ABCDĐEFGHKLMNPSTUVXYZ]-\d{5}")