Skip to content

Commit

Permalink
Add license_plate for zh_TW (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanghsieh committed May 4, 2023
1 parent 47a3806 commit 294768d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions faker/providers/automotive/zh_TW/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from .. import Provider as AutomotiveProvider


class Provider(AutomotiveProvider):
"""Implement automotive provider for ``zh_TW`` locale.
Sources:
- https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Taiwan
"""

license_formats = (
"####-??",
"??-####",
# Commercial vehicles since 2012
"???-###",
# New format since 2014
"???-####",
)
11 changes: 11 additions & 0 deletions tests/providers/test_automotive.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,14 @@ class TestNlBe(_SimpleAutomotiveTestMixin):
"""Test nl_BE automotive provider methods"""

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})")


class TestZhTw(_SimpleAutomotiveTestMixin):
"""Test zh_TW automotive provider methods"""

license_plate_pattern: Pattern = re.compile(
r"([A-Z]{2}-\d{4})|" # prior 2012 v1
r"(\d{4}-[A-Z]{2})|" # prior 2012 v2
r"([A-Z]{3}-\d{4})|" # new format since 2014
r"([A-Z]{3}-\d{3})", # commercial cars since 2012
)

0 comments on commit 294768d

Please sign in to comment.