Skip to content

Commit 809bbc8

Browse files
committed
Close initials_separator ordering gap; drop remaining redundant restores
test_initials_separator_default_on_constants now runs after the test that mutates initials_separator, so it actually verifies the autouse fixture restored the default rather than merely asserting an unrelated value. Also removes the last manual CONSTANTS restore assignments in test_output_format.py and test_constants.py, now redundant since the autouse fixture in conftest.py covers all of these attributes.
1 parent 681a9d0 commit 809bbc8

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

tests/test_constants.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def test_clear_removes_all_entries(self) -> None:
9999

100100
def test_empty_attribute_default(self) -> None:
101101
from nameparser.config import CONSTANTS
102-
_orig = CONSTANTS.empty_attribute_default
103102
CONSTANTS.empty_attribute_default = None
104103
hn = HumanName("")
105104
self.m(hn.title, None, hn)
@@ -108,7 +107,6 @@ def test_empty_attribute_default(self) -> None:
108107
self.m(hn.last, None, hn)
109108
self.m(hn.suffix, None, hn)
110109
self.m(hn.nickname, None, hn)
111-
CONSTANTS.empty_attribute_default = _orig
112110

113111
def test_empty_attribute_on_instance(self) -> None:
114112
hn = HumanName("", None)

tests/test_initials.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ def test_initials_delimiter_constants(self) -> None:
7070
hn = HumanName("Doe, John A. Kenneth, Jr.")
7171
self.m(hn.initials(), "J; A; K; D;", hn)
7272

73-
def test_initials_separator_default_on_constants(self) -> None:
74-
from nameparser.config import CONSTANTS
75-
self.assertEqual(CONSTANTS.initials_separator, " ")
76-
7773
def test_initials_list(self) -> None:
7874
hn = HumanName("Andrew Boris Petersen")
7975
self.m(hn.initials_list(), ["A", "B", "P"], hn)
@@ -196,3 +192,10 @@ def test_initials_separator_constants_multi_part_middle(self) -> None:
196192
CONSTANTS.initials_format = "{first}{middle}{last}"
197193
hn = HumanName("Doe, John A. Kenneth")
198194
self.m(hn.initials(), "JAKD", hn)
195+
196+
def test_initials_separator_default_on_constants(self) -> None:
197+
# Runs after test_initials_separator_constants_multi_part_middle so that,
198+
# in file/definition order, it verifies the autouse fixture restored
199+
# CONSTANTS.initials_separator rather than leaking the "" set above.
200+
from nameparser.config import CONSTANTS
201+
self.assertEqual(CONSTANTS.initials_separator, " ")

tests/test_output_format.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,22 @@ def test_formatting_init_argument(self) -> None:
1212

1313
def test_formatting_constants_attribute(self) -> None:
1414
from nameparser.config import CONSTANTS
15-
_orig = CONSTANTS.string_format
1615
CONSTANTS.string_format = "TEST2"
1716
hn = HumanName("Rev John A. Kenneth Doe III (Kenny)")
1817
self.assertEqual(str(hn), "TEST2")
19-
CONSTANTS.string_format = _orig
2018

2119
def test_capitalize_name_constants_attribute(self) -> None:
2220
from nameparser.config import CONSTANTS
2321
CONSTANTS.capitalize_name = True
2422
hn = HumanName("bob v. de la macdole-eisenhower phd")
2523
self.assertEqual(str(hn), "Bob V. de la MacDole-Eisenhower Ph.D.")
26-
CONSTANTS.capitalize_name = False
2724

2825
def test_force_mixed_case_capitalization_constants_attribute(self) -> None:
2926
from nameparser.config import CONSTANTS
3027
CONSTANTS.force_mixed_case_capitalization = True
3128
hn = HumanName('Shirley Maclaine')
3229
hn.capitalize()
3330
self.assertEqual(str(hn), "Shirley MacLaine")
34-
CONSTANTS.force_mixed_case_capitalization = False
3531

3632
def test_capitalize_name_and_force_mixed_case_capitalization_constants_attributes(self) -> None:
3733
from nameparser.config import CONSTANTS

0 commit comments

Comments
 (0)