Skip to content

Commit c1a2236

Browse files
authored
docs(tests): state project tests' behaviour without change-relative narrative (#1103) (#2203)
Rewrite comments and docstrings in tests/project that describe a fix relative to the change ("now", "no longer", "used to", "before #NNN", "the old X") as timeless statements of the behaviour pinned or the defect guarded against; cut history that only reads as history. Prose only: every changed module's AST is identical once docstrings are stripped.
1 parent 71d7be7 commit c1a2236

46 files changed

Lines changed: 435 additions & 519 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tests/project/test_actionlint_in_lint_1967.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""#1967: Lint runs actionlint, pinned to a checksum-verified release.
33
4-
Nothing ran actionlint over the workflows before #1967. Lint's ``lint`` job
5-
has an ``actionlint`` step that downloads one release, named by
6-
``ACTIONLINT_VERSION``, checks it against ``ACTIONLINT_SHA256`` before unpacking
4+
Lint's ``lint`` job has an ``actionlint`` step that downloads one release, named
5+
by ``ACTIONLINT_VERSION``, checks it against ``ACTIONLINT_SHA256`` before unpacking
76
it, and runs it over every workflow. The version is 1.7.12 or newer: the
87
workflows use YAML anchors, which 1.7.7 cannot read.
98

‎tests/project/test_build_leftovers_1773.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
:file:`MANIFEST.in` names a directory the repository tracks or ignores. Every
66
other line there changes what the template selects (#1794).
77
* No reStructuredText is tracked outside ``docs/`` (the #719 ruling), the
8-
examples' Markdown READMEs still ship in the sdist, and nothing points at a
9-
README path that no longer exists.
8+
examples' Markdown READMEs ship in the sdist, and nothing points at a
9+
README path that does not exist.
1010
1111
"""
1212

‎tests/project/test_bump_version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_an_indented_version_key_belongs_to_its_own_reference(self) -> None:
158158
def test_a_file_with_no_version_field_is_refused(self) -> None:
159159
# A file that is *present* and has no field to update means the shape has
160160
# changed underneath the script. Rewriting nothing while reporting success
161-
# is the staleness this change exists to stop, so it raises instead.
161+
# is the staleness this check exists to stop, so it raises instead.
162162
without = '\n'.join(line for line in FIXTURE.splitlines()
163163
if not line.startswith('version:')) + '\n'
164164

‎tests/project/test_changelog_md.py‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_rule_6_collapses_blank_runs_and_drops_a_leading_one(self) -> None:
252252
# structurally rather than collapsed afterwards by a ``\n{3,}`` substitution
253253
# over the joined text. Same answer between blocks -- a run of blank lines
254254
# is one paragraph break however long it is -- and a better one before the
255-
# first block, where the substitution used to leave two empty lines.
255+
# first block, where such a substitution leaves two empty lines.
256256
markdown = self.convert(
257257
'\n\n9.9.9 -- 2026-01-02\n===================\n\n\n\n'
258258
'One paragraph.\n\n\nAnother.\n'
@@ -593,26 +593,24 @@ def test_a_simple_table_is_fatal(self) -> None:
593593
)
594594

595595
def test_a_sub_heading_underline_joined_into_the_prose_is_fatal(self) -> None:
596-
# Retargeted from ``-`` to ``^``. Rule 1 used to consume ``=`` alone, so a
597-
# ``-`` underlined sub-heading was joined onto its heading text by rule 6 and
598-
# would have vanished into a paragraph -- which is what this rejected. The
599-
# by-module changelog restructure made ``-`` and ``~`` real heading levels
600-
# that rule 1 now converts, so the old input converts cleanly and **this test
601-
# failed**: ``_reject`` is built on ``assertRaises(ResidualMarkupError)``, and
602-
# nothing raises any more. The retarget was required to keep the guard
603-
# exercised, not a tidy-up of a weak assertion. ``^`` is still outside rule 1's
604-
# level map while remaining in ``_RESIDUAL``'s alternation, so it tests the
605-
# same guard on a character the converter genuinely does not handle.
596+
# ``^``, not ``-``: an underline rule 1 does not convert is joined onto its
597+
# heading text by rule 6 and would vanish into a paragraph, which is what this
598+
# rejects. The by-module changelog makes ``-`` and ``~`` real heading levels
599+
# that rule 1 converts, so a ``-`` sub-heading converts cleanly and would leave
600+
# ``_reject``, built on ``assertRaises(ResidualMarkupError)``, with nothing to
601+
# raise. ``^`` is outside rule 1's level map while remaining in
602+
# ``_RESIDUAL``'s alternation, so it exercises the guard on a character the
603+
# converter genuinely does not handle.
606604
self._reject('\nA sub heading\n^^^^^^^^^^^^^\n\nSome prose.\n',
607605
'setext underline joined')
608606

609607
def test_the_two_new_sub_heading_levels_become_atx_headings(self) -> None:
610-
# The other half of the same change: ``-`` and ``~`` must now *convert*
611-
# rather than be rejected, one ATX level deeper each, so that the by-module
612-
# sections and their Added/Changed/Fixed subsections survive into
613-
# ``CHANGELOG.md``. Against the old converter this does not reach the
614-
# assertions at all -- ``render()`` raises ``ResidualMarkupError`` on the
615-
# joined ``A module --------`` first, which is what makes this a real check
608+
# The other half: ``-`` and ``~`` *convert* rather than being rejected, one
609+
# ATX level deeper each, so that the by-module sections and their
610+
# Added/Changed/Fixed subsections survive into ``CHANGELOG.md``. Against a
611+
# converter that handles ``=`` alone this does not reach the assertions at
612+
# all -- ``render()`` raises ``ResidualMarkupError`` on the joined
613+
# ``A module --------`` first, which is what makes this a real check
616614
# rather than a restatement of current behaviour.
617615
index = self.make_tree(
618616
entry=ENTRY + '\nA module\n--------\n\nAdded\n~~~~~\n\nSome prose.\n')
@@ -625,10 +623,11 @@ def test_the_two_new_sub_heading_levels_become_atx_headings(self) -> None:
625623
self.assertNotIn('Added ~~~~~', rendered)
626624

627625
def test_an_over_long_sub_heading_underline_is_fatal(self) -> None:
628-
# ``_RESIDUAL``'s comment now claims ``=``, ``-`` and ``~`` all need to stay in
626+
# ``_RESIDUAL``'s comment claims ``=``, ``-`` and ``~`` all need to stay in
629627
# its alternation, because rule 1 fires only on an *exact* length match while
630-
# reStructuredText merely requires the underline to be no shorter. Only ``=``
631-
# was pinned, so the other two thirds of that claim rode on the comment alone.
628+
# reStructuredText merely requires the underline to be no shorter. The test
629+
# below pins ``=``; this pins the other two, so no part of that claim rides on
630+
# the comment alone.
632631
for underline in ('-' * 18, '~' * 18):
633632
with self.subTest(underline=underline[0]):
634633
self._reject(f'\nA sub heading\n{underline}\n\nSome prose.\n',
@@ -722,8 +721,8 @@ def test_a_cited_line_holds_the_construct_it_was_cited_for(self) -> None:
722721
f'line {number} of the entry does not hold the cited construct')
723722

724723
def test_a_cited_line_can_lie_past_the_end_of_the_converted_body(self) -> None:
725-
# The bound that made the old numbers provably wrong: they were counted in
726-
# the body, so they could never reach a construct written below it.
724+
# The bound that makes body-counted line numbers provably wrong: counted in
725+
# the body, they could never reach a construct written below it.
727726
entry = padded_entry('and then :term:`sys.modules` at the very end.')
728727
body = changelog_md.convert(entry)
729728

‎tests/project/test_conda_intel_cli_upload_2044.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
44
``anaconda/actions/upload-package`` v0.3.1 installs its CLI from
55
``anaconda.sh/releases/stable/v0.2.1/ana-darwin-x86_64``, which returns 404, so
6-
the step "Upload conda packages to Anaconda" failed on every Intel leg of
7-
``conda-dist`` in :file:`.github/workflows/cron-conda.yml` and would on ``conda``
8-
in :file:`.github/workflows/create-release.yml`. That step skips the Intel
9-
leg, and "Upload conda packages to Anaconda (Intel)" runs there alone, making
10-
the action's own ``anaconda --token … upload --user …`` call from conda-forge's
11-
anaconda-client, with ``--skip-existing``.
6+
the action cannot upload from an Intel leg of ``conda-dist`` in
7+
:file:`.github/workflows/cron-conda.yml` or of ``conda`` in
8+
:file:`.github/workflows/create-release.yml`. The step "Upload conda packages to
9+
Anaconda" therefore skips the Intel leg, and "Upload conda packages to Anaconda
10+
(Intel)" runs there alone, making the action's own
11+
``anaconda --token … upload --user …`` call from conda-forge's anaconda-client,
12+
with ``--skip-existing``.
1213
1314
Each step's ``if:`` is evaluated per matrix leg with
1415
:func:`tests.project.test_release_gates.evaluate_condition`. The CLI step's

‎tests/project/test_conda_intel_miniforge_2044.py‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# -*- coding: utf-8 -*-
22
"""#2044: the conda jobs' ``macos-26-intel`` legs install Miniforge.
33
4-
The step "Conda environment creation and activation" of ``conda-dist`` in
4+
Given no installer, setup-miniconda downloads
5+
``Miniconda3-latest-MacOSX-x86_64.sh`` on the Intel runner. That installer is
6+
frozen at conda 25.7.0, which conflicts with conda-forge's conda-content-trust
7+
plugin and has no py314 build. So on the Intel legs, the step "Conda environment
8+
creation and activation" of ``conda-dist`` in
59
:file:`.github/workflows/cron-conda.yml` and of ``conda`` in
6-
:file:`.github/workflows/create-release.yml` named no installer, so on the Intel
7-
runner setup-miniconda downloaded ``Miniconda3-latest-MacOSX-x86_64.sh``. That
8-
installer is frozen at conda 25.7.0, which conflicts with conda-forge's
9-
conda-content-trust plugin and has no py314 build. The Intel legs pass
10+
:file:`.github/workflows/create-release.yml` passes
1011
``miniforge-version: latest``; every other leg passes an empty string, which
1112
names no installer, so it keeps the bundled or downloaded Miniconda.
1213
@@ -17,12 +18,12 @@
1718
``installer-url`` first, then Miniforge when ``miniforge-version`` or
1819
``miniforge-variant`` is non-empty, else Miniconda.
1920
20-
#2123: with Miniforge, the Intel legs broke twice more. Installing the matrix
21-
Python into base rebuilt conda-forge's libmambapy at 2.10.0, which
22-
conda-libmamba-solver 26.10.0 cannot drive, so the Intel legs leave base's
23-
Python alone, as 3.15 does everywhere; :class:`TestTheIntelLegsKeepBasesPython`
24-
pins that. And conda-build 26.9's rpath relocation failed on the vendored chardet
25-
extensions, so :file:`conda/pypcapkit/meta.yaml` turns it off on osx-64 alone;
21+
#2123: with Miniforge, installing the matrix Python into base rebuilds
22+
conda-forge's libmambapy at 2.10.0, which conda-libmamba-solver 26.10.0 cannot
23+
drive, so the Intel legs leave base's Python alone, as 3.15 does everywhere;
24+
:class:`TestTheIntelLegsKeepBasesPython` pins that. And conda-build 26.9's rpath
25+
relocation fails on the vendored chardet extensions, so
26+
:file:`conda/pypcapkit/meta.yaml` turns it off on osx-64 alone;
2627
:class:`TestOsx64SkipsBinaryRelocation` evaluates that line's selector as
2728
conda-build does, for each leg's platform.
2829

‎tests/project/test_conda_no_windows_steps_1967.py‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# -*- coding: utf-8 -*-
22
"""#1967: the conda jobs keep no step or ``case`` arm for a runner they have no leg on.
33
4-
``conda`` in :file:`.github/workflows/create-release.yml` and ``conda-dist`` in
5-
:file:`.github/workflows/cron-conda.yml` had no ``windows-latest`` leg from 2023
6-
until #2060, yet carried ``Install and Setup (Windows)``, ``Setup Conda Distribution
7-
(Windows)``, the ``matrix.os != 'windows-latest'`` guards on their twins, and a
8-
``windows-latest`` arm in each ``case "${{ matrix.os }}"``: code no run reached.
4+
This guards ``conda`` in :file:`.github/workflows/create-release.yml` and
5+
``conda-dist`` in :file:`.github/workflows/cron-conda.yml` against code no run
6+
reaches: in a job with no ``windows-latest`` leg, a Windows-only step such as
7+
``Install and Setup (Windows)``, a ``matrix.os != 'windows-latest'`` guard on its
8+
twin, or a ``windows-latest`` arm in a ``case "${{ matrix.os }}"``.
99
1010
* :class:`TestNoDeadRunnerCode` pins that no step's ``if:`` or
1111
``continue-on-error`` names a runner label the job's matrix lacks, no ``case``
1212
arm maps one, :file:`util/release_conda.py`, which both jobs' steps run since
1313
#1967, maps no label that neither job has a leg on, and, with no Windows leg,
14-
no step is Windows-only. So adding a
15-
Windows leg back means adding its steps back deliberately, rather than
16-
reviving ones nobody has run. #2060 did so for both jobs, whose Windows
17-
steps are therefore live.
18-
* :class:`TestTheCheckSeesDeadCode` feeds :func:`dead` the jobs as they stood
19-
before, rebuilt from the current ones, so the pin cannot pass by reading
20-
nothing, and ``conda-dist`` without its Windows leg, whose steps must then read
21-
as dead.
14+
no step is Windows-only. So a Windows leg comes with its steps added
15+
deliberately, rather than reviving ones nobody has run, as #2060 added both
16+
jobs' Windows legs and steps.
17+
* :class:`TestTheCheckSeesDeadCode` feeds :func:`dead` the jobs with such dead
18+
Windows code rebuilt into them from the current ones, so the pin cannot pass by
19+
reading nothing, and ``conda-dist`` without its Windows leg, whose steps must
20+
then read as dead.
2221
2322
"""
2423

@@ -112,12 +111,12 @@ def without_windows(step: 'dict[str, Any]') -> 'dict[str, Any]':
112111

113112

114113
class TestTheCheckSeesDeadCode(unittest.TestCase):
115-
""":func:`dead` reports each kind of dead code the jobs held before #1967."""
114+
""":func:`dead` reports each kind of dead runner code: a step, a guard and a ``case`` arm."""
116115

117116
def test_it_reports_a_windows_step_guard_and_arm(self) -> None:
118117
for name, job_id in JOBS:
119118
spec = copy.deepcopy(_workflows.job(name, job_id))
120-
# #2060: conda-dist as it stood before its Windows leg came back.
119+
# #2060: the job without its Windows leg.
121120
spec['strategy']['matrix']['os'] = [os for os in spec['strategy']['matrix']['os']
122121
if not WINDOWS.search(os)]
123122
spec['steps'] = [without_windows(step) for step in spec['steps']

‎tests/project/test_conda_platform_pin_refresh_1851.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def test_json_without_releases_leaves_the_pin_and_warns(self) -> None:
387387
"PyPI's JSON has no releases")])
388388

389389
def test_a_pin_no_release_can_move_to_warns_with_the_missing_tags(self) -> None:
390-
# #2025: no release has a cp38 wheel, so the pin used to stay without a word.
390+
# #2025: no release has a cp38 wheel, so the pin stays, and must not stay without a word.
391391
result, notes = vendor().refresh(table(), lambda name: recorded(), lambda name: '50.0.2',
392392
('3.8', *PYTHONS), TODAY)
393393
self.assertEqual(result, table())
@@ -406,7 +406,7 @@ def test_a_pin_no_single_release_serves_warns_for_every_tag(self) -> None:
406406
'on osx-64 at once')])
407407

408408
def test_a_pin_whose_release_lost_a_wheel_warns_with_the_tag_it_lacks(self) -> None:
409-
# #2028: 47.0.0 still has every wheel, so the 48.0.1 pin used to stay without a word.
409+
# #2028: 47.0.0 still has every wheel, so the 48.0.1 pin stays, and must not stay without a word.
410410
result, notes = self.refresh(lost_wheel())
411411
self.assertEqual(result, table())
412412
self.assertEqual(notes, [('warning', 'cryptography 48.0.1 on osx-64 stays as it is, and may no longer '

0 commit comments

Comments
 (0)