Skip to content

Commit 3a43a3d

Browse files
committed
sort automotive provider tests
1 parent 22aa0d2 commit 3a43a3d

File tree

1 file changed

+155
-155
lines changed

1 file changed

+155
-155
lines changed

tests/providers/test_automotive.py

Lines changed: 155 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,6 @@ class TestAzAz(_SimpleAutomotiveTestMixin):
5555
license_plate_pattern = re.compile(r"\d{2}-[A-Z]{2}-\d{3}")
5656

5757

58-
class TestSkSk(_SimpleAutomotiveTestMixin):
59-
"""Test sk_SK automotive provider methods"""
60-
61-
license_plate_pattern: Pattern = re.compile(r"(?P<prefix>[A-Z]{2})\d{3}[A-Z]{2}")
62-
63-
def perform_extra_checks(self, license_plate, match):
64-
assert match.group("prefix") in SkSkAutomotiveProvider.license_plate_prefix
65-
66-
67-
class TestPtBr(_SimpleAutomotiveTestMixin):
68-
"""Test pt_BR automotive provider methods"""
69-
70-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{1}[A-Z]{1}\d{2}")
71-
72-
73-
class TestPtPt(_SimpleAutomotiveTestMixin):
74-
"""Test pt_PT automotive provider methods"""
75-
76-
license_plate_pattern: Pattern = re.compile(
77-
r"\d{2}-\d{2}-[A-Z]{2}|" r"\d{2}-[A-Z]{2}-\d{2}|" r"[A-Z]{2}-\d{2}-\d{2}|" r"[A-Z]{2}-\d{2}-[A-Z]{2}",
78-
)
79-
80-
81-
class TestHeIl(_SimpleAutomotiveTestMixin):
82-
license_plate_pattern: Pattern = re.compile(r"(\d{3}-\d{2}-\d{3})|(\d{2}-\d{3}-\d{2})")
83-
84-
85-
class TestHuHu(_SimpleAutomotiveTestMixin):
86-
"""Test hu_HU automotive provider methods"""
87-
88-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{3}")
89-
90-
9158
class TestDeAt(_SimpleAutomotiveTestMixin):
9259
"""Test de_AT automotive provider methods"""
9360

@@ -98,6 +65,12 @@ def perform_extra_checks(self, license_plate, match):
9865
assert len(license_plate) in (8, 9)
9966

10067

68+
class TestDeCh(_SimpleAutomotiveTestMixin):
69+
"""Test de_CH automotive provider methods"""
70+
71+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2}-\d{1,3}\s?\d{0,3}")
72+
73+
10174
class TestDeDe(_SimpleAutomotiveTestMixin):
10275
"""Test de_DE automotive provider methods"""
10376

@@ -110,18 +83,10 @@ def perform_extra_checks(self, license_plate, match):
11083
assert match.group("prefix") in DeDeAutomotiveProvider.license_plate_prefix
11184

11285

113-
class TestSvSe(_SimpleAutomotiveTestMixin):
114-
"""Test sv_SE automotive provider methods"""
115-
116-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3} \d{2}[\dA-Z]")
117-
86+
class TestElGr(_SimpleAutomotiveTestMixin):
87+
"""Test el_GR automotive provider methods"""
11888

119-
class TestPlPl:
120-
def test_License_plate(self, faker, num_samples):
121-
pattern: Pattern = re.compile(r"{patterns}".format(patterns="|".join(faker.license_plate_regex_formats())))
122-
for _ in range(num_samples):
123-
plate = faker.license_plate()
124-
assert pattern.fullmatch(plate)
89+
license_plate_pattern = re.compile(r"^(?P<prefix>[A-Z]{2,3}) \d{4}$")
12590

12691

12792
class TestEnPh(_SimpleAutomotiveTestMixin):
@@ -145,62 +110,6 @@ def test_protocol_plate(self, faker, num_samples):
145110
assert int(protocol_plate) != 15 and 1 <= int(protocol_plate) <= 17
146111

147112

148-
class TestFilPh(TestEnPh):
149-
"""Test fil_PH automotive provider methods"""
150-
151-
pass
152-
153-
154-
class TestTlPh(TestEnPh):
155-
"""Test tl_PH automotive provider methods"""
156-
157-
pass
158-
159-
160-
class TestRuRu(_SimpleAutomotiveTestMixin):
161-
"""Test ru_RU automotive provider methods"""
162-
163-
_plate_letters = "".join(RuRuAutomotiveProvider.license_plate_letters)
164-
license_plate_pattern: Pattern = re.compile(
165-
r"(?:"
166-
r"(?P<private_plate_prefix>[{0}]\d\d\d[{0}][{0}])|"
167-
r"(?P<public_transport_plate_prefix>[{0}][{0}]\d\d\d)|"
168-
r"(?P<trailer_plate_prefix>[{0}][{0}]\d\d\d\d)|"
169-
r"(?P<police_plate_prefix>[{0}]\d\d\d\d)|"
170-
r"(?P<military_plate_prefix>\d\d\d\d[{0}][{0}])|"
171-
r"(?P<plate_number_special>00\dCD\d|00\dD\d\d\d|00\dT\d\d\d)"
172-
r") (?P<plate_suffix>.*)".format(_plate_letters),
173-
)
174-
175-
def perform_extra_checks(self, license_plate, match):
176-
plate_suffix = match.group("plate_suffix")
177-
assert plate_suffix in RuRuAutomotiveProvider.license_plate_suffix
178-
179-
def test_vehicle_category(self, faker, num_samples):
180-
for _ in range(num_samples):
181-
vehicle_category = faker.vehicle_category()
182-
assert isinstance(vehicle_category, str)
183-
assert vehicle_category in RuRuAutomotiveProvider.vehicle_categories
184-
185-
186-
class TestFrFr(_SimpleAutomotiveTestMixin):
187-
"""Test fr_FR automotive provider methods"""
188-
189-
license_plate_pattern: Pattern = re.compile(r"\d{3}-[A-Z]{3}-\d{2}|[A-Z]{2}-\d{3}-[A-Z]{2}")
190-
191-
192-
class TestItIt(_SimpleAutomotiveTestMixin):
193-
"""Test it_IT automotive provider methods"""
194-
195-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2}\d{3}[A-Z]{2}")
196-
197-
198-
class TestNoNo(_SimpleAutomotiveTestMixin):
199-
"""Test no_NO automotive provider methods"""
200-
201-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2} \d{5}")
202-
203-
204113
class TestEsCo(_SimpleAutomotiveTestMixin):
205114
"""Test es_CO automotive provider methods"""
206115

@@ -241,48 +150,50 @@ def test_plate_format(self, faker, num_samples):
241150
assert self.new_format_pattern.match(plate) or self.old_format_pattern.match(plate)
242151

243152

244-
class TestThTh(_SimpleAutomotiveTestMixin):
245-
"""Test th_TH automotive provider methods"""
153+
class TestFiFi(_SimpleAutomotiveTestMixin):
154+
"""Test fi_FI automotive provider methods"""
246155

247-
license_plate_pattern: Pattern = re.compile(
248-
r"(\d [ก-ฮ]{2} \d{1,4})|" # car
249-
r"([ก-ฮ]{2} \d{1,4})|" # car
250-
r"([ก-ฮ]{3} \d{1,3})|" # motorcycle
251-
r"(\d{2}-\d{4})", # truck
252-
)
156+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{3}")
253157

254158

255-
class TestTrTr(_SimpleAutomotiveTestMixin):
256-
"""Test tr_TR automotive provider methods"""
159+
class TestFilPh(TestEnPh):
160+
"""Test fil_PH automotive provider methods"""
257161

258-
license_plate_pattern: Pattern = re.compile(
259-
r"\d{2} [A-Z] \d{4}|"
260-
r"\d{2} [A-Z] \d{5}|"
261-
r"\d{2} [A-Z]{2} \d{3}|"
262-
r"\d{2} [A-Z]{2} \d{4}|"
263-
r"\d{2} [A-Z]{3} \d{2}|"
264-
r"\d{2} [A-Z]{3} \d{3}",
265-
)
162+
pass
266163

267-
def perform_extra_checks(self, license_plate, match):
268-
[city_code, letters, _] = license_plate.split(" ")
269-
assert int(city_code) in range(1, 82)
270-
assert all(letter in TrTrAutomotiveProvider.ascii_uppercase_turkish for letter in letters)
271164

165+
class TestFrFr(_SimpleAutomotiveTestMixin):
166+
"""Test fr_FR automotive provider methods"""
272167

273-
class TestRoRo(_SimpleAutomotiveTestMixin):
274-
"""Test ro_RO automotive provider methods"""
168+
license_plate_pattern: Pattern = re.compile(r"\d{3}-[A-Z]{3}-\d{2}|[A-Z]{2}-\d{3}-[A-Z]{2}")
275169

276-
license_plate_pattern: Pattern = re.compile(r"(?P<prefix>[A-Z]{1,2})-\d{2,3}-[A-Z]{3}")
277170

278-
def perform_extra_checks(self, license_plate, match):
279-
assert match.group("prefix") in RoRoAutomotiveProvider.license_plate_prefix
171+
class TestHeIl(_SimpleAutomotiveTestMixin):
172+
license_plate_pattern: Pattern = re.compile(r"(\d{3}-\d{2}-\d{3})|(\d{2}-\d{3}-\d{2})")
280173

281174

282-
class TestElGr(_SimpleAutomotiveTestMixin):
283-
"""Test el_GR automotive provider methods"""
175+
class TestHuHu(_SimpleAutomotiveTestMixin):
176+
"""Test hu_HU automotive provider methods"""
284177

285-
license_plate_pattern = re.compile(r"^(?P<prefix>[A-Z]{2,3}) \d{4}$")
178+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{3}")
179+
180+
181+
class TestItIt(_SimpleAutomotiveTestMixin):
182+
"""Test it_IT automotive provider methods"""
183+
184+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2}\d{3}[A-Z]{2}")
185+
186+
187+
class TestKoKr(_SimpleAutomotiveTestMixin):
188+
license_plate_pattern: Pattern = re.compile(
189+
r"^\d{2,3}[가나다라마거너더러머버서어저고노도로모보소오조구누두루무부수우주]\d{4}$"
190+
)
191+
192+
193+
class TestNlBe(_SimpleAutomotiveTestMixin):
194+
"""Test nl_BE automotive provider methods"""
195+
196+
license_plate_pattern: Pattern = re.compile(r"(\d{3}-[A-Z]{3})|" r"([A-Z]{3}-\d{3})|" r"([1-2]-[A-Z]{3}-\d{3})")
286197

287198

288199
class TestNlNl(_SimpleAutomotiveTestMixin):
@@ -317,16 +228,76 @@ def test_plate_motorbike(self, faker, num_samples):
317228
assert self.license_plate_motorbike_pattern.match(plate)
318229

319230

320-
class TestViVn(_SimpleAutomotiveTestMixin):
321-
"""Test vi_VN automotive provider methods"""
231+
class TestNoNo(_SimpleAutomotiveTestMixin):
232+
"""Test no_NO automotive provider methods"""
322233

323-
license_plate_pattern: Pattern = re.compile(r"\d{2}[ABCDĐEFGHKLMNPSTUVXYZ]-\d{5}")
234+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2} \d{5}")
324235

325236

326-
class TestFiFi(_SimpleAutomotiveTestMixin):
327-
"""Test fi_FI automotive provider methods"""
237+
class TestPlPl:
238+
def test_License_plate(self, faker, num_samples):
239+
pattern: Pattern = re.compile(r"{patterns}".format(patterns="|".join(faker.license_plate_regex_formats())))
240+
for _ in range(num_samples):
241+
plate = faker.license_plate()
242+
assert pattern.fullmatch(plate)
243+
244+
245+
class TestPtBr(_SimpleAutomotiveTestMixin):
246+
"""Test pt_BR automotive provider methods"""
247+
248+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{1}[A-Z]{1}\d{2}")
249+
250+
251+
class TestPtPt(_SimpleAutomotiveTestMixin):
252+
"""Test pt_PT automotive provider methods"""
253+
254+
license_plate_pattern: Pattern = re.compile(
255+
r"\d{2}-\d{2}-[A-Z]{2}|" r"\d{2}-[A-Z]{2}-\d{2}|" r"[A-Z]{2}-\d{2}-\d{2}|" r"[A-Z]{2}-\d{2}-[A-Z]{2}",
256+
)
257+
258+
259+
class TestRoRo(_SimpleAutomotiveTestMixin):
260+
"""Test ro_RO automotive provider methods"""
261+
262+
license_plate_pattern: Pattern = re.compile(r"(?P<prefix>[A-Z]{1,2})-\d{2,3}-[A-Z]{3}")
263+
264+
def perform_extra_checks(self, license_plate, match):
265+
assert match.group("prefix") in RoRoAutomotiveProvider.license_plate_prefix
328266

329-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3}-\d{3}")
267+
268+
class TestRuRu(_SimpleAutomotiveTestMixin):
269+
"""Test ru_RU automotive provider methods"""
270+
271+
_plate_letters = "".join(RuRuAutomotiveProvider.license_plate_letters)
272+
license_plate_pattern: Pattern = re.compile(
273+
r"(?:"
274+
r"(?P<private_plate_prefix>[{0}]\d\d\d[{0}][{0}])|"
275+
r"(?P<public_transport_plate_prefix>[{0}][{0}]\d\d\d)|"
276+
r"(?P<trailer_plate_prefix>[{0}][{0}]\d\d\d\d)|"
277+
r"(?P<police_plate_prefix>[{0}]\d\d\d\d)|"
278+
r"(?P<military_plate_prefix>\d\d\d\d[{0}][{0}])|"
279+
r"(?P<plate_number_special>00\dCD\d|00\dD\d\d\d|00\dT\d\d\d)"
280+
r") (?P<plate_suffix>.*)".format(_plate_letters),
281+
)
282+
283+
def perform_extra_checks(self, license_plate, match):
284+
plate_suffix = match.group("plate_suffix")
285+
assert plate_suffix in RuRuAutomotiveProvider.license_plate_suffix
286+
287+
def test_vehicle_category(self, faker, num_samples):
288+
for _ in range(num_samples):
289+
vehicle_category = faker.vehicle_category()
290+
assert isinstance(vehicle_category, str)
291+
assert vehicle_category in RuRuAutomotiveProvider.vehicle_categories
292+
293+
294+
class TestSkSk(_SimpleAutomotiveTestMixin):
295+
"""Test sk_SK automotive provider methods"""
296+
297+
license_plate_pattern: Pattern = re.compile(r"(?P<prefix>[A-Z]{2})\d{3}[A-Z]{2}")
298+
299+
def perform_extra_checks(self, license_plate, match):
300+
assert match.group("prefix") in SkSkAutomotiveProvider.license_plate_prefix
330301

331302

332303
class TestSqAl(_SimpleAutomotiveTestMixin):
@@ -335,36 +306,46 @@ class TestSqAl(_SimpleAutomotiveTestMixin):
335306
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2} \d{3}[A-Z]{2}")
336307

337308

338-
class TestDeCh(_SimpleAutomotiveTestMixin):
339-
"""Test de_CH automotive provider methods"""
309+
class TestSvSe(_SimpleAutomotiveTestMixin):
310+
"""Test sv_SE automotive provider methods"""
340311

341-
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2}-\d{1,3}\s?\d{0,3}")
312+
license_plate_pattern: Pattern = re.compile(r"[A-Z]{3} \d{2}[\dA-Z]")
342313

343314

344-
class TestNlBe(_SimpleAutomotiveTestMixin):
345-
"""Test nl_BE automotive provider methods"""
315+
class TestThTh(_SimpleAutomotiveTestMixin):
316+
"""Test th_TH automotive provider methods"""
346317

347-
license_plate_pattern: Pattern = re.compile(r"(\d{3}-[A-Z]{3})|" r"([A-Z]{3}-\d{3})|" r"([1-2]-[A-Z]{3}-\d{3})")
318+
license_plate_pattern: Pattern = re.compile(
319+
r"(\d [ก-ฮ]{2} \d{1,4})|" # car
320+
r"([ก-ฮ]{2} \d{1,4})|" # car
321+
r"([ก-ฮ]{3} \d{1,3})|" # motorcycle
322+
r"(\d{2}-\d{4})", # truck
323+
)
348324

349325

350-
class TestZhCn(_SimpleAutomotiveTestMixin):
351-
"""Test zh_CN automotive provider methods"""
326+
class TestTlPh(TestEnPh):
327+
"""Test tl_PH automotive provider methods"""
352328

353-
license_plate_pattern: Pattern = re.compile(
354-
r"^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}-[A-Z0-9]{5}"
355-
)
329+
pass
356330

357331

358-
class TestZhTw(_SimpleAutomotiveTestMixin):
359-
"""Test zh_TW automotive provider methods"""
332+
class TestTrTr(_SimpleAutomotiveTestMixin):
333+
"""Test tr_TR automotive provider methods"""
360334

361335
license_plate_pattern: Pattern = re.compile(
362-
r"([A-Z]{2}-\d{4})|" # prior 2012 v1
363-
r"(\d{4}-[A-Z]{2})|" # prior 2012 v2
364-
r"([A-Z]{3}-\d{4})|" # new format since 2014
365-
r"([A-Z]{3}-\d{3})", # commercial cars since 2012
336+
r"\d{2} [A-Z] \d{4}|"
337+
r"\d{2} [A-Z] \d{5}|"
338+
r"\d{2} [A-Z]{2} \d{3}|"
339+
r"\d{2} [A-Z]{2} \d{4}|"
340+
r"\d{2} [A-Z]{3} \d{2}|"
341+
r"\d{2} [A-Z]{3} \d{3}",
366342
)
367343

344+
def perform_extra_checks(self, license_plate, match):
345+
[city_code, letters, _] = license_plate.split(" ")
346+
assert int(city_code) in range(1, 82)
347+
assert all(letter in TrTrAutomotiveProvider.ascii_uppercase_turkish for letter in letters)
348+
368349

369350
class TestUkUa(_SimpleAutomotiveTestMixin):
370351
license_plate_pattern: Pattern = re.compile(r"[A-Z]{2}\d{4}[A-Z]{2}")
@@ -398,7 +379,26 @@ def test_region_code(self, faker):
398379
assert "14" == faker.plate_region_code(region_name="Lviv")
399380

400381

401-
class TestKoKr(_SimpleAutomotiveTestMixin):
382+
class TestViVn(_SimpleAutomotiveTestMixin):
383+
"""Test vi_VN automotive provider methods"""
384+
385+
license_plate_pattern: Pattern = re.compile(r"\d{2}[ABCDĐEFGHKLMNPSTUVXYZ]-\d{5}")
386+
387+
388+
class TestZhCn(_SimpleAutomotiveTestMixin):
389+
"""Test zh_CN automotive provider methods"""
390+
402391
license_plate_pattern: Pattern = re.compile(
403-
r"^\d{2,3}[가나다라마거너더러머버서어저고노도로모보소오조구누두루무부수우주]\d{4}$"
392+
r"^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新]{1}[A-Z]{1}-[A-Z0-9]{5}"
393+
)
394+
395+
396+
class TestZhTw(_SimpleAutomotiveTestMixin):
397+
"""Test zh_TW automotive provider methods"""
398+
399+
license_plate_pattern: Pattern = re.compile(
400+
r"([A-Z]{2}-\d{4})|" # prior 2012 v1
401+
r"(\d{4}-[A-Z]{2})|" # prior 2012 v2
402+
r"([A-Z]{3}-\d{4})|" # new format since 2014
403+
r"([A-Z]{3}-\d{3})", # commercial cars since 2012
404404
)

0 commit comments

Comments
 (0)