Skip to content

3.1.1: pyupgrade --py38-plush generated changes trashes test suite #449

Closed
@kloczek

Description

@kloczek

I've been trying to drop python<=3.7 support by filter all code over pyupgrade --py38-plush and after that test suite started failing

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-autoapi-3.1.1-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-autoapi-3.1.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1
configfile: pyproject.toml
plugins: datadir-1.5.0, regressions-2.5.0, timeout-2.3.1, typeguard-4.2.1, flexmock-0.12.1
collected 311 items

tests/python/test_own_page_option.py .......F.....F.....F......F...........                                                                                                           [ 12%]
tests/python/test_parser.py ..........                                                                                                                                                [ 15%]
tests/python/test_pyintegration.py ..F....F...F............s..........................................                                                                                [ 36%]
tests/test_astroid_utils.py ......................................................................................................................................................... [ 86%]
........................................                                                                                                                                              [ 99%]
tests/test_integration.py ...                                                                                                                                                         [100%]

========================================================================================= FAILURES ==========================================================================================
___________________________________________________________________________________ TestClass.test_class ____________________________________________________________________________________

self = <test_own_page_option.TestClass object at 0x7f7b7a647af0>, parse = <function parse.<locals>.parser at 0x7f7b784c6830>

    def test_class(self, parse):
        class_path = "_build/html/autoapi/package/Class.html"
        class_file = parse(class_path)

        class_sig = class_file.find(id="package.Class")
        assert class_sig
        class_ = class_sig.parent
        docstring = class_.find_all("p")[1]
>       assert docstring.text == "This is a class."
E       AssertionError: assert 'Class var docstring' == 'This is a class.'
E
E         - This is a class.
E         + Class var docstring

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_own_page_option.py:262: AssertionError
__________________________________________________________________________________ TestFunction.test_class __________________________________________________________________________________

self = <test_own_page_option.TestFunction object at 0x7f7b7a6454e0>, parse = <function parse.<locals>.parser at 0x7f7b780556c0>

    def test_class(self, parse):
        class_path = "_build/html/autoapi/package/Class.html"
        class_file = parse(class_path)

        class_sig = class_file.find(id="package.Class")
        assert class_sig
        class_ = class_sig.parent
        docstring = class_.find_all("p")[1]
>       assert docstring.text == "This is a class."
E       AssertionError: assert 'Class var docstring' == 'This is a class.'
E
E         - This is a class.
E         + Class var docstring

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_own_page_option.py:476: AssertionError
___________________________________________________________________________________ TestMethod.test_class ___________________________________________________________________________________

self = <test_own_page_option.TestMethod object at 0x7f7b7a646f80>, parse = <function parse.<locals>.parser at 0x7f7b7868acb0>

    def test_class(self, parse):
        class_path = "_build/html/autoapi/package/Class.html"
        class_file = parse(class_path)

        class_sig = class_file.find(id="package.Class")
        assert class_sig
        class_ = class_sig.parent
        docstring = class_.find_all("p")[1]
>       assert docstring.text == "This is a class."
E       AssertionError: assert 'Class var docstring' == 'This is a class.'
E
E         - This is a class.
E         + Class var docstring

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_own_page_option.py:666: AssertionError
_________________________________________________________________________________ TestAttribute.test_class __________________________________________________________________________________

self = <test_own_page_option.TestAttribute object at 0x7f7b7a647f40>, parse = <function parse.<locals>.parser at 0x7f7b77dc35b0>

    def test_class(self, parse):
        class_path = "_build/html/autoapi/package/Class.html"
        class_file = parse(class_path)

        class_sig = class_file.find(id="package.Class")
        assert class_sig
        class_ = class_sig.parent
>       docstring = class_.find_all("p")[1]
E       IndexError: list index out of range

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_own_page_option.py:860: IndexError
__________________________________________________________________________ TestSimpleModule.test_show_inheritance ___________________________________________________________________________

self = <test_pyintegration.TestSimpleModule object at 0x7f7b7a192020>, parse = <function parse.<locals>.parser at 0x7f7b779d3370>

    def test_show_inheritance(self, parse):
        example_file = parse("_build/html/autoapi/example/index.html")

        foo = example_file.find(id="example.Foo")
        foo_docstring = foo.parent.find("dd").contents[0]
>       assert foo_docstring.text.startswith("Bases:")
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7f7b789b2d40>('Bases:')
E        +    where <built-in method startswith of str object at 0x7f7b789b2d40> = 'Can we parse arguments from the class docstring?'.startswith
E        +      where 'Can we parse arguments from the class docstring?' = <p>Can we parse arguments from the class docstring?</p>.text

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_pyintegration.py:142: AssertionError
___________________________________________________________________________ TestMovedConfPy.test_show_inheritance ___________________________________________________________________________

self = <test_pyintegration.TestMovedConfPy object at 0x7f7b7a1905b0>, parse = <function parse.<locals>.parser at 0x7f7b777ea9e0>

    def test_show_inheritance(self, parse):
        example_file = parse("_build/html/autoapi/example/index.html")

        foo = example_file.find(id="example.Foo")
        foo_docstring = foo.parent.find("dd").contents[0]
>       assert foo_docstring.text.startswith("Bases:")
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7f7b77a36480>('Bases:')
E        +    where <built-in method startswith of str object at 0x7f7b77a36480> = 'Can we parse arguments from the class docstring?'.startswith
E        +      where 'Can we parse arguments from the class docstring?' = <p>Can we parse arguments from the class docstring?</p>.text

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_pyintegration.py:142: AssertionError
_______________________________________________________________ TestSimpleModuleDifferentPrimaryDomain.test_show_inheritance ________________________________________________________________

self = <test_pyintegration.TestSimpleModuleDifferentPrimaryDomain object at 0x7f7b7a190460>, parse = <function parse.<locals>.parser at 0x7f7b77795b40>

    def test_show_inheritance(self, parse):
        example_file = parse("_build/html/autoapi/example/index.html")

        foo = example_file.find(id="example.Foo")
        foo_docstring = foo.parent.find("dd").contents[0]
>       assert foo_docstring.text.startswith("Bases:")
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7f7b7777d370>('Bases:')
E        +    where <built-in method startswith of str object at 0x7f7b7777d370> = 'Can we parse arguments from the class docstring?'.startswith
E        +      where 'Can we parse arguments from the class docstring?' = <p>Can we parse arguments from the class docstring?</p>.text

/home/tkloczko/rpmbuild/BUILD/sphinx-autoapi-3.1.1/tests/python/test_pyintegration.py:142: AssertionError
===================================================================================== warnings summary ======================================================================================
tests/python/test_pyintegration.py: 52 warnings
  /usr/lib/python3.10/site-packages/sphinx/ext/autodoc/__init__.py:827: RemovedInSphinx80Warning: Returning tuples of (name, object) as the second return value from get_object_members() is deprecated. Return ObjectMember(name, object) instances instead.
    for (mname, member, isattr) in self.filter_members(members, want_all):

tests/test_integration.py::TestIntegration::test_template_overrides
  /home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-autoapi-3.1.1-2.fc37.x86_64/usr/lib/python3.10/site-packages/autoapi/extension.py:107: RemovedInSphinx80Warning: Sphinx 8 will drop support for representing paths as strings. Use "pathlib.Path" or "os.fspath" instead.
    elif app.srcdir != os.getcwd():

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
SKIPPED [1] tests/python/test_pyintegration.py:598: PEP-695 support requires Python >=3.12
FAILED tests/python/test_own_page_option.py::TestClass::test_class - AssertionError: assert 'Class var docstring' == 'This is a class.'
FAILED tests/python/test_own_page_option.py::TestFunction::test_class - AssertionError: assert 'Class var docstring' == 'This is a class.'
FAILED tests/python/test_own_page_option.py::TestMethod::test_class - AssertionError: assert 'Class var docstring' == 'This is a class.'
FAILED tests/python/test_own_page_option.py::TestAttribute::test_class - IndexError: list index out of range
FAILED tests/python/test_pyintegration.py::TestSimpleModule::test_show_inheritance - AssertionError: assert False
FAILED tests/python/test_pyintegration.py::TestMovedConfPy::test_show_inheritance - AssertionError: assert False
FAILED tests/python/test_pyintegration.py::TestSimpleModuleDifferentPrimaryDomain::test_show_inheritance - AssertionError: assert False
================================================================== 7 failed, 303 passed, 1 skipped, 53 warnings in 27.37s ===================================================================

It would be good to prepare sphinx-autoapi code to make it upgradeable using pyupgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Other ImprovementImprovements that aren't targeted at users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions