Skip to content

Cover initials_separator/suffix_delimiter in autouse CONSTANTS restore#200

Merged
derek73 merged 2 commits into
masterfrom
test-scalar-config-attrs-cleanup
Jul 4, 2026
Merged

Cover initials_separator/suffix_delimiter in autouse CONSTANTS restore#200
derek73 merged 2 commits into
masterfrom
test-scalar-config-attrs-cleanup

Conversation

@derek73

@derek73 derek73 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add initials_separator and suffix_delimiter to _SCALAR_CONFIG_ATTRS in tests/conftest.py so the autouse fixture snapshots and restores them, like it already does for other scalar CONSTANTS attributes.
  • Fixes a live test leak: without suffix_delimiter in that list, test_suffix_delimiter_constants_level leaked CONSTANTS.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.
  • Remove the now-redundant manual try/finally / restore-assignment blocks in 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 in tests/test_output_format.py (string_format, capitalize_name, force_mixed_case_capitalization) and tests/test_constants.py (empty_attribute_default) — all now covered by the fixture.
  • Reorder test_initials_separator_default_on_constants to run after test_initials_separator_constants_multi_part_middle, so it actually proves the fixture restores initials_separator (previously it ran first in file order and would not have caught a leak).

These attributes were being mutated directly on the global CONSTANTS singleton by individual tests but weren't covered by the shared autouse restore fixture, so those tests had to manually restore state (or, in suffix_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

derek73 added 2 commits July 3, 2026 20:39
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.
@derek73 derek73 self-assigned this Jul 4, 2026
@derek73 derek73 added the bug label Jul 4, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 4, 2026
@derek73 derek73 merged commit 006b45f into master Jul 4, 2026
8 checks passed
@derek73 derek73 deleted the test-scalar-config-attrs-cleanup branch July 4, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant