Skip to content

Commit a0e535c

Browse files
Add generating random french licence plates (#1122)
* Add initial failing test * Add french car licence plates * Fixed flake8 issue * Removed one source to pass flake8 tests Co-authored-by: Simon Persson <[email protected]>
1 parent f874509 commit a0e535c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .. import Provider as AutomotiveProvider
2+
3+
4+
class Provider(AutomotiveProvider):
5+
# Source (english): https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France
6+
license_formats = (
7+
# New format
8+
'??-###-??',
9+
# Old format for plates < 2009
10+
'###-???-##',
11+
)

tests/providers/test_automotive.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,16 @@ def test_ru_RU_plate_format(self):
133133
def test_vehicle_category(self):
134134
category = self.fake.vehicle_category()
135135
assert isinstance(category, str)
136+
137+
138+
class TestFrFR(unittest.TestCase):
139+
140+
def setUp(self):
141+
self.fake = Faker('fr_FR')
142+
Faker.seed(0)
143+
self.pattern = re.compile(r'^\d{3}-[A-Z]{3}-\d{2}$|^[A-Z]{2}-\d{3}-[A-Z]{2}')
144+
145+
def test_fr_FR_plate_format(self):
146+
plate = self.fake.license_plate()
147+
assert isinstance(plate, str)
148+
assert self.pattern.match(plate)

0 commit comments

Comments
 (0)