Skip to content

gh-116040: [Enum] fix test_empty_names test #116508

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

Merged
merged 6 commits into from
Mar 11, 2024

Conversation

ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Mar 8, 2024

@ethanfurman ethanfurman added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir skip news 3.12 only security fixes 3.13 bugs and security fixes needs backport to 3.12 only security fixes labels Mar 8, 2024
@ethanfurman ethanfurman self-assigned this Mar 8, 2024
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@ethanfurman ethanfurman merged commit 3c0dcef into python:main Mar 11, 2024
@miss-islington-app
Copy link

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 11, 2024
* and fix _not_given usage
(cherry picked from commit 3c0dcef)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@bedevere-app
Copy link

bedevere-app bot commented Mar 11, 2024

GH-116619 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 11, 2024
@ethanfurman ethanfurman deleted the enum-zero_not_none_test branch March 11, 2024 22:13
ethanfurman added a commit that referenced this pull request Mar 11, 2024
…6619)

* and fix _not_given usage

(cherry picked from commit 3c0dcef)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@befeleme
Copy link
Contributor

With this change, test_enum_class of the Sphinx' test suite failed with the traceback below. See names=<not given> when expecting names=None in the output. Is this expected?

_______________________________ test_enum_class ________________________________

app = <SphinxTestApp buildername='html'>

    @pytest.mark.sphinx('html', testroot='ext-autodoc')
    def test_enum_class(app):
        options = {"members": None}
        actual = do_autodoc(app, 'class', 'target.enums.EnumCls', options)
    
        if sys.version_info[:2] >= (3, 12):
            args = ('(value, names=None, *values, module=None, '
                    'qualname=None, type=None, start=1, boundary=None)')
        elif sys.version_info[:2] >= (3, 11):
            args = ('(value, names=None, *, module=None, qualname=None, '
                    'type=None, start=1, boundary=None)')
        else:
            args = '(value)'
    
>       assert list(actual) == [
            '',
            '.. py:class:: EnumCls' + args,
            '   :module: target.enums',
            '',
            '   this is enum class',
            '',
            '',
            '   .. py:method:: EnumCls.say_goodbye()',
            '      :module: target.enums',
            '      :classmethod:',
            '',
            '      a classmethod says good-bye to you.',
            '',
            '',
            '   .. py:method:: EnumCls.say_hello()',
            '      :module: target.enums',
            '',
            '      a method says hello to you.',
            '',
            '',
            '   .. py:attribute:: EnumCls.val1',
            '      :module: target.enums',
            '      :value: 12',
            '',
            '      doc for val1',
            '',
            '',
            '   .. py:attribute:: EnumCls.val2',
            '      :module: target.enums',
            '      :value: 23',
            '',
            '      doc for val2',
            '',
            '',
            '   .. py:attribute:: EnumCls.val3',
            '      :module: target.enums',
            '      :value: 34',
            '',
            '      doc for val3',
            '',
        ]
E       AssertionError: assert ['', '.. py:c...ass', '', ...] == ['', '.. py:c...ass', '', ...]
E         At index 1 diff: '.. py:class:: EnumCls(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)' != '.. py:class:: EnumCls(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)'
E         Use -v to get more diff

tests/test_ext_autodoc.py:1419: AssertionError

@ethanfurman
Copy link
Member Author

@befeleme, Yes, it is expected. With some of the recent changes, None became a possible valid value, so the default for names was replaced with a custom sentinel whose repr is <not given>.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes skip news tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants