Skip to content

test: main is red on 3.11/3.12 — the re.sub DeprecationWarning test is ungated and CPython only warns from 3.13 #819

Description

@JarryShaw

Describe the bug

main is red on Python 3.11 and 3.12. tests/vendor/test_re_sub_positional_flag_unit.py::RuntimeDeprecationWarningTests::test_positional_flag_shape_would_warn asserts a DeprecationWarning that CPython only emits from 3.13, with no version guard:

tests/vendor/test_re_sub_positional_flag_unit.py:218
    with self.assertWarns(DeprecationWarning):
        re.sub(self.PATTERN, ' ', 'a\nb', re.MULTILINE)
AssertionError: DeprecationWarning not triggered
tests/vendor/test_re_sub_positional_flag_unit.py:221: AssertionError
1 failed, 1831 passed, 76 skipped, 45005 subtests passed in 485.74s

Four failing legs — Python 3.11, Python 3.12, Engines Python 3.11, Engines Python 3.12 — are one defect, not four.

Measured: on 3.14.7 the call warns; on 3.11/3.12 it does not. The 'count' is passed as positional argument deprecation landed in CPython 3.13.

Expected behavior

The test skips, or asserts the absence of the warning, below 3.13. The file's own module docstring at :25 already states the boundary — "It is also a live DeprecationWarning on Python 3.13+" — so the knowledge was there and the guard was not. grep -nE "version_info|skipIf|skipUnless" over the file returns nothing.

Additional context

Introduced by #813 (merged as 55e1b756e), and I cleared that PR as review: good-to-go on incomplete CI — it showed 27✅ 0❌ when I looked, but the 3.11/3.12 legs had not finished. That is my error, not the author's: its own verification ran on 3.14 only, which is the documented local interpreter, and the matrix is what exists to catch exactly this.

The sibling test immediately below, test_flags_keyword_shape_does_not_warn, is version-independent and correct — it asserts the absence of a warning, which holds on every version. Only the positive assertion needs gating.

Fix shape, cheapest first:

  1. @unittest.skipIf(sys.version_info < (3, 13), '...') on that one method, naming the CPython version in the reason.
  2. Or invert it: assert the warning on 3.13+ and its absence below, so both branches are pinned rather than one being skipped.

(2) is better — it keeps coverage on every leg instead of going dark on two of them, and it makes the version boundary itself a tested fact rather than a comment.

Note this is the second time today a test pinned a runtime symptom without gating its version. #788 had the mirror image: typing.final only records __final__ from 3.11, and the guard's boundary had to be pinned by an AST-derived test (test_the_shim_switches_at_the_version_that_added_the_dunder). That is the pattern to copy here.

Related: #813, #796, #788.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugciPull requests that change CI or workflow configuration (ci: subject prefix)testPull requests that add or correct tests (test: subject prefix)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions