Skip to content

Fix failure in test_cfunction with new Python snapshots: "asctime([time_tuple])" != "asctime([tuple])" - #14683

Closed
mitya57 wants to merge 1 commit into
sphinx-doc:masterfrom
mitya57:time-tuple
Closed

mitya57 wants to merge 1 commit into
sphinx-doc:masterfrom
mitya57:time-tuple

Conversation

@mitya57

@mitya57 mitya57 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

It fixes the test failure which the latest Python snapshots from 3.13, 3.14 and main branches:

=================================== FAILURES ===================================
________________________________ test_cfunction ________________________________
    def test_cfunction() -> None:
        actual = do_autodoc('function', 'time.asctime')
>       assert actual == [
            '',
            '.. py:function:: asctime([tuple]) -> string',
            '   :module: time',
            '',
            "   Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.",
            '   When the time tuple is not present, current time as returned by localtime()',
            '   is used.',
            '',
        ]
E       AssertionError: assert ['', '.. py:f...ltime()', ...] == ['', '.. py:f...ltime()', ...]
E         
E         At index 1 diff: '.. py:function:: asctime([time_tuple]) -> string' != '.. py:function:: asctime([tuple]) -> string'
E         
E         Full diff:
E           [
E               '',
E         -     '.. py:function:: asctime([tuple]) -> string',...
E         
E         ...Full output truncated (10 lines hidden), use '-vv' to show
tests/test_ext_autodoc/test_ext_autodoc_autofunction.py:126: AssertionError

References

AI Disclosure

No AI tools used.

@jayaddison

Copy link
Copy Markdown
Contributor

For changes that are a result of upgrades in Python (cpython) we typically use sys.version_info comparisons to decide what format of output to expect in Sphinx tests (often autodoc ones).

That could be tricky in this case though, because as mentioned, these Debian builds are from latest-commit on cpython branches, not from tagged releases.

It might be worth preparing sys.version_info comparisons that use the anticipated next release versions (3.13.16 and 3.14.8 respectively, I think), scheduled to include these changes, to manage the conditional test expectations?

@mitya57
mitya57 force-pushed the time-tuple branch 2 times, most recently from b3e72d1 to f80e8c0 Compare September 18, 2026 18:41
…uple])"

See python/cpython#155790 (it will be part of
upcoming v3.14.8 and v3.13.16 releases).
@jayaddison

Copy link
Copy Markdown
Contributor

Sorry! When I wrote my previous comment I mistakenly thought that this was an issue thread, not a pull request. I see now that it is a PR and includes a fix. I will begin reviewing it now.

@mitya57

mitya57 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Done. I don't know why Python 3.12 test failed though, maybe you can retry it?

@jayaddison

Copy link
Copy Markdown
Contributor

Thanks @mitya57. That is a known-flaky test case (test_numfig_disabled_warn), I think: ref #14104

Comment on lines +143 to +145
# FIXME: Correct upper bound on the next line if the change gets backported
# to 3.15 branch: https://github.com/python/cpython/pull/155804.
or (3, 15) <= sys.version_info < (3, 16)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are close to the scheduled 3.15.0 release (PEP-0790), there does seem to be a possibility that the time_tuple output in help(time.asctime) will not be included in that version -- so this conditional seems reasonable 👍

@jayaddison jayaddison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me; thanks again @mitya57

@jayaddison

Copy link
Copy Markdown
Contributor

I lack the permissions to retry the failed Python3.12 unit test pipeline; however I think that it would be likely to succeed if re-run.

@mitya57

mitya57 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

No longer needed with 378a332, we are checking another function now.

@mitya57 mitya57 closed this Oct 20, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants