Cover initials_separator/suffix_delimiter in autouse CONSTANTS restore#200
Merged
Conversation
These scalar attributes were mutated directly by tests without being in _SCALAR_CONFIG_ATTRS, so the autouse fixture wasn't restoring them and tests relied on manual try/finally blocks instead. Adding them to the list lets us drop the now-redundant manual restoration.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
initials_separatorandsuffix_delimiterto_SCALAR_CONFIG_ATTRSintests/conftest.pyso the autouse fixture snapshots and restores them, like it already does for other scalar CONSTANTS attributes.suffix_delimiterin that list,test_suffix_delimiter_constants_levelleakedCONSTANTS.suffix_delimiter = " - "into the next test (test_suffix_delimiter_none_by_default_known_limitation), which depends on the default (unset) delimiter behavior — this was an order-dependent failure waiting to happen, not just a style nit.test_initials_delimiter_constants,test_initials_format_constants,test_initials_separator_constants_multi_part_middle(tests/test_initials.py),test_suffix_delimiter_constants_level(tests/test_suffixes.py), plus the remaining manual restores intests/test_output_format.py(string_format,capitalize_name,force_mixed_case_capitalization) andtests/test_constants.py(empty_attribute_default) — all now covered by the fixture.test_initials_separator_default_on_constantsto run aftertest_initials_separator_constants_multi_part_middle, so it actually proves the fixture restoresinitials_separator(previously it ran first in file order and would not have caught a leak).These attributes were being mutated directly on the global
CONSTANTSsingleton by individual tests but weren't covered by the shared autouse restore fixture, so those tests had to manually restore state (or, insuffix_delimiter's case, silently relied on file order to avoid leaking into a later test). Bringing them into the fixture's scope removes the per-test boilerplate and keeps the "which global attrs are test-safe" list centralized.Test plan
python -m pytest tests/ -q— 1182 passed, 4 skipped, 22 xfailed