-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathtest_comma_variants.py
More file actions
34 lines (26 loc) · 1.37 KB
/
Copy pathtest_comma_variants.py
File metadata and controls
34 lines (26 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from nameparser import HumanName
from tests.base import HumanNameTestBase
class HumanNameCommaVariantsTests(HumanNameTestBase):
"""Non-ASCII comma characters should split "Last, First" the same as ',' (#265)."""
def test_arabic_comma_splits_lastname_format(self) -> None:
hn = HumanName("سلمان، محمد")
self.m(hn.first, "محمد", hn)
self.m(hn.last, "سلمان", hn)
def test_fullwidth_comma_splits_lastname_format(self) -> None:
hn = HumanName("Smith,John")
self.m(hn.first, "John", hn)
self.m(hn.last, "Smith", hn)
def test_arabic_comma_does_not_pollute_output(self) -> None:
hn = HumanName("سلمان، محمد")
self.assertNotIn("،", hn.last)
self.assertNotIn("،", str(hn))
def test_trailing_arabic_comma_stripped(self) -> None:
# matches ASCII behavior: a single word with a trailing comma has
# nothing after the comma, so it's a bare name, not "Last,"
hn = HumanName("سلمان،")
self.m(hn.first, "سلمان", hn)
# The v1 test for a custom regexes dict omitting the 'commas' key (the
# EMPTY_REGEX shatter guard) died with the mechanism: Constants(regexes=
# ...) raises TypeError in 2.0 (deliberate divergence, migration spec
# section 3 uniform rule) -- pinned in test_python_api.py's
# test_override_regex_raises.