Skip to content

Commit b76fa5f

Browse files
derek73claude
andcommitted
fix: correct doctest expected output to match Python repr format
- Replace unordered SetManager assertions with +SKIP (set ordering is non-deterministic) - Fix dict key ordering in as_dict() doctest to match insertion order - Fix string repr in initials/initials_list doctests (single quotes, not double) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e8f45c9 commit b76fa5f

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

nameparser/config/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
::
1010
1111
>>> from nameparser.config import CONSTANTS
12-
>>> CONSTANTS.titles.remove('hon').add('chemistry','dean') # doctest: +ELLIPSIS
13-
SetManager({'msgt', ..., 'adjutant'})
12+
>>> CONSTANTS.titles.remove('hon').add('chemistry','dean') # doctest: +SKIP
1413
1514
You can also adjust the configuration of individual instances by passing
1615
``None`` as the second argument upon instantiation.
@@ -19,8 +18,7 @@
1918
2019
>>> from nameparser import HumanName
2120
>>> hn = HumanName("Dean Robert Johns", None)
22-
>>> hn.C.titles.add('dean') # doctest: +ELLIPSIS
23-
SetManager({'msgt', ..., 'adjutant'})
21+
>>> hn.C.titles.add('dean') # doctest: +SKIP
2422
>>> hn.parse_full_name() # need to run this again after config changes
2523
2624
**Potential Gotcha**: If you do not pass ``None`` as the second argument,

nameparser/parser.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ def as_dict(self, include_empty: bool = True) -> dict[str, str]:
222222
223223
>>> name = HumanName("Bob Dole")
224224
>>> name.as_dict()
225-
{'last': 'Dole', 'suffix': '', 'title': '', 'middle': '', 'nickname': '', 'first': 'Bob'}
225+
{'title': '', 'first': 'Bob', 'middle': '', 'last': 'Dole', 'suffix': '', 'nickname': ''}
226226
>>> name.as_dict(False)
227-
{'last': 'Dole', 'first': 'Bob'}
227+
{'first': 'Bob', 'last': 'Dole'}
228228
229229
"""
230230
d = {}
@@ -261,10 +261,10 @@ def initials_list(self) -> list[str]:
261261
262262
>>> name = HumanName("Sir Bob Andrew Dole")
263263
>>> name.initials_list()
264-
["B", "A", "D"]
264+
['B', 'A', 'D']
265265
>>> name = HumanName("J. Doe")
266266
>>> name.initials_list()
267-
["J", "D"]
267+
['J', 'D']
268268
"""
269269
first_initials_list = [self.__process_initial__(name, True) for name in self.first_list if name]
270270
middle_initials_list = [self.__process_initial__(name) for name in self.middle_list if name]
@@ -285,13 +285,13 @@ def initials(self) -> str:
285285
286286
>>> name = HumanName("Sir Bob Andrew Dole")
287287
>>> name.initials()
288-
"B. A. D."
288+
'B. A. D.'
289289
>>> name = HumanName("Sir Bob Andrew Dole", initials_format="{first} {middle}")
290290
>>> name.initials()
291-
"B. A."
291+
'B. A.'
292292
>>> name = HumanName("Doe, John A.", initials_delimiter="", initials_separator="")
293293
>>> name.initials()
294-
"J A D"
294+
'J A D'
295295
"""
296296

297297
first_initials_list = [self.__process_initial__(name, True) for name in self.first_list if name]

0 commit comments

Comments
 (0)