Skip to content

De-duplicate needs_strict_codec between tests/conftest.py and tests/test_verify.py #608

Description

@pbean

needs_strict_codec now exists twice in the test tree: the shared copy in tests/conftest.py and a local one in tests/test_verify.py.

State

The marker skips a test when the host codec can decode byte 0xff — every ISO-8859-x and cp125x codec maps all 256 byte values, so under such a locale a strict-decode test goes vacuously green rather than exercising the fault it is named for.

The two are byte-identical in condition and skip reason.

Why the duplication was left in place

test_verify.py is otherwise untouched by the #380/#383 fix. De-duplicating it would have dragged a large, unrelated file into a bundled fix whose whole discipline was to claim exactly what it fixed and no more. Deliberate, and named in that PR's "Out of scope" section — filed here so it does not simply rot.

Asked for

Delete the local copy and its _codec_rejects_bad_byte helper from tests/test_verify.py; import the shared one from conftest, as the other three files do.

Worth carrying over rather than dropping: the comment above the local copy (tests/test_verify.py:56-58) records that CI is always on the exercising side of this skip — the Linux legs run UTF-8 and the Windows legs set PYTHONUTF8=1 (.github/workflows/ci.yml). That fact belongs with the shared definition, which currently does not state it.

Verification

Mechanical, but confirm the tests still run rather than newly skipping — a marker refactor that silently flips three tests to skipped is indistinguishable from green. -rs on the affected file, or an explicit assertion on the collected outcome, is enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Robustness, enhancement, tests, or docs worth schedulingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions