Content-Length: 325314 | pFad | http://github.com/python/cpython/pull/136479

F5 gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimization levels by Grivvus · Pull Request #136479 · python/cpython · GitHub
Skip to content

gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimization levels #136479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Grivvus
Copy link

@Grivvus Grivvus commented Jul 9, 2025

Output before:

test test.test_pydoc.test_pydoc failed -- Traceback (most recent call last):
  File "/home/grivvus/cpython/Lib/test/test_pydoc/test_pydoc.py", line 1464, in test_special_form
    self.assertIn('NoReturn = class _SpecialForm(_Final)', doc)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'NoReturn = class _SpecialForm(_Final)' not found in 'Python Library Documentation: _SpecialForm in module typing object\n\nNoReturn = class _SpecialForm(_Final, _NotIterable)\n |  NoReturn(getitem)\n |\n |  # Internal indicator of special typing constructs.\n |  # See __doc__ instance attribute for specific docs.\n |\n |  Method resolution order:\n |      _SpecialForm\n |      _Final\n |      _NotIterable\n |      builtins.object\n |\n |  Methods defined here:\n |\n |  __call__(self, *args, **kwds)\n |      Call self as a function.\n |\n |  __getattr__(self, item)\n |\n |  __getitem__(self, parameters)\n |\n |  __init__(self, getitem)\n |      Initialize self.  See help(type(self)) for accurate signature.\n |\n |  __instancecheck__(self, obj)\n |      Check if an object is an instance.\n |\n |  __mro_entries__(self, bases)\n |\n |  __or__(self, other)\n |      Return self|value.\n |\n |  __reduce__(self)\n |      Helper for pickle.\n |\n |  __repr__(self)\n |      Return repr(self).\n |\n |  __ror__(self, other)\n |      Return value|self.\n |\n |  __subclasscheck__(self, cls)\n |      Check if a class is a subclass.\n |\n |  ----------------------------------------------------------------------\n |  Class methods inherited from _Final:\n |\n |  __init_subclass__(*args, **kwds)\n |      This method is called when a class is subclassed.\n |\n |      The default implementation does nothing. It may be\n |      overridden to extend subclasses.\n |\n |  ----------------------------------------------------------------------\n |  Data descriptors inherited from _Final:\n |\n |  __weakref__\n |      list of weak references to the object\n |\n |  ----------------------------------------------------------------------\n |  Data and other attributes inherited from _NotIterable:\n |\n |  __iter__ = None\n'

0:00:02 load avg: 0.60 [1/1/1] test.test_pydoc.test_pydoc failed (1 failure)

== Tests result: FAILURE ==

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 9, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 9, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Jul 9, 2025
@bedevere-app bedevere-app bot mentioned this pull request Jul 9, 2025
8 tasks
@StanFromIreland StanFromIreland requested a review from sobolevn July 10, 2025 06:29
@@ -1461,7 +1461,7 @@ def test_special_form(self):
self.assertIn('NoReturn = typing.NoReturn', doc)
self.assertIn(typing.NoReturn.__doc__.strip().splitlines()[0], doc)
else:
self.assertIn('NoReturn = class _SpecialForm(_Final)', doc)
self.assertIn('NoReturn = class _SpecialForm(_Final, _NotIterable)', doc)
Copy link
Member

@StanFromIreland StanFromIreland Jul 10, 2025

Choose a reason for hiding this comment

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

This parameter was added 3 years ago, and popped up now because -OO optimizes away typing.NoReturn.__doc__. I think we need a better solution here, since this is not properly tested.

cc @hauntsaninja who I see added this test

Copy link
Contributor

@hauntsaninja hauntsaninja Jul 10, 2025

Choose a reason for hiding this comment

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

I didn't add the test, I just fixed it up to accommodate another change. The test was added in #30253

Not sure that there's a good solution to be had really, maybe you have ideas! pydoc does depend on __doc__... if we want to guarantee tests pass on -OO we probably just have to run tests with -OO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/136479

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy