Skip to content
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

0.6.0: pytest fails in tests/test_python_files.py units #62

Closed
kloczek opened this issue Mar 11, 2024 · 6 comments
Closed

0.6.0: pytest fails in tests/test_python_files.py units #62

kloczek opened this issue Mar 11, 2024 · 6 comments

Comments

@kloczek
Copy link

kloczek commented Mar 11, 2024

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using installer module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")
Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0
configfile: pyproject.toml
plugins: sphinx-0.6.0
collected 51 items

tests/test_doc2test.py .....                                             [  9%]
tests/test_options.py ..........                                         [ 29%]
tests/test_python_files.py FFFFFFFFFF                                    [ 49%]
tests/test_sphinx_doctest.py ................                            [ 80%]
tests/test_text_files.py ..........                                      [100%]

=================================== FAILURES ===================================
_____________________ test_syntax_error_in_module_doctest ______________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_syntax_error_in_module_doctest0')>

    def test_syntax_error_in_module_doctest(testdir: Testdir) -> None:

        testdir.makepyfile(
            textwrap.dedent(
                """
            '''
            .. testcode::

                3+

            .. testoutput::

                3
            '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(
            ["UNEXPECTED EXCEPTION: SyntaxError('invalid syntax',*"]
        )
E       Failed: nomatch: "UNEXPECTED EXCEPTION: SyntaxError('invalid syntax',*"
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_syntax_error_in_module_doctest0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '___________ ERROR collecting test_syntax_error_in_module_doctest.py ____________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_syntax_error_in_module_doctest.py - TypeError: import_path() missi...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.11s ==============================='
E       remains unmatched: "UNEXPECTED EXCEPTION: SyntaxError('invalid syntax',*"

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:25: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_syntax_error_in_module_doctest0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
___________ ERROR collecting test_syntax_error_in_module_doctest.py ____________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_syntax_error_in_module_doctest.py - TypeError: import_path() missi...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.11s ===============================
_________________________ test_failing_module_doctest __________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_failing_module_doctest0')>

    def test_failing_module_doctest(testdir: Testdir) -> None:

        testdir.makepyfile(
            textwrap.dedent(
                """
            '''
            .. testcode::

                print(2+5)

            .. testoutput::

                3
            '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       assert "FAILURES" in result.stdout.str()
E       AssertionError: assert 'FAILURES' in '============================= test session starts ==============================\nplatform linux -- Python 3.9.18, py...ring collection !!!!!!!!!!!!!!!!!!!!\n=============================== 1 error in 0.08s ==============================='
E        +  where '============================= test session starts ==============================\nplatform linux -- Python 3.9.18, py...ring collection !!!!!!!!!!!!!!!!!!!!\n=============================== 1 error in 0.08s ===============================' = <bound method LineMatcher.str of <_pytest.pytester.LineMatcher object at 0x7f61d373e1c0>>()
E        +    where <bound method LineMatcher.str of <_pytest.pytester.LineMatcher object at 0x7f61d373e1c0>> = <_pytest.pytester.LineMatcher object at 0x7f61d373e1c0>.str
E        +      where <_pytest.pytester.LineMatcher object at 0x7f61d373e1c0> = <RunResult ret=ExitCode.INTERRUPTED len(stdout.lines)=15 len(stderr.lines)=0 duration=0.13s>.stdout

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:49: AssertionError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_failing_module_doctest0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
_______________ ERROR collecting test_failing_module_doctest.py ________________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_failing_module_doctest.py - TypeError: import_path() missing 1 req...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
________________________ test_failing_function_doctest _________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_failing_function_doctest0')>

    def test_failing_function_doctest(testdir: Testdir) -> None:
        testdir.makepyfile(
            textwrap.dedent(
                """
            # simple comment
            GLOBAL_VAR = True

            def func():
                '''
                .. testcode::

                    print(2+5)

                .. testoutput::

                    3
                '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       assert "FAILURES" in result.stdout.str()
E       AssertionError: assert 'FAILURES' in '============================= test session starts ==============================\nplatform linux -- Python 3.9.18, py...ring collection !!!!!!!!!!!!!!!!!!!!\n=============================== 1 error in 0.08s ==============================='
E        +  where '============================= test session starts ==============================\nplatform linux -- Python 3.9.18, py...ring collection !!!!!!!!!!!!!!!!!!!!\n=============================== 1 error in 0.08s ===============================' = <bound method LineMatcher.str of <_pytest.pytester.LineMatcher object at 0x7f61d326fc70>>()
E        +    where <bound method LineMatcher.str of <_pytest.pytester.LineMatcher object at 0x7f61d326fc70>> = <_pytest.pytester.LineMatcher object at 0x7f61d326fc70>.str
E        +      where <_pytest.pytester.LineMatcher object at 0x7f61d326fc70> = <RunResult ret=ExitCode.INTERRUPTED len(stdout.lines)=15 len(stderr.lines)=0 duration=0.13s>.stdout

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:77: AssertionError
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_failing_function_doctest0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
______________ ERROR collecting test_failing_function_doctest.py _______________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_failing_function_doctest.py - TypeError: import_path() missing 1 r...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
_________________________ test_working_module_doctest __________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest0')>

    def test_working_module_doctest(testdir: Testdir) -> None:

        testdir.makepyfile(
            textwrap.dedent(
                """
            '''
            .. testcode::

                print(2+5)

            .. testoutput::

                7
            '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 1 passed in *"])
E       Failed: nomatch: '*=== 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '_______________ ERROR collecting test_working_module_doctest.py ________________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_working_module_doctest.py - TypeError: import_path() missing 1 req...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 1 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:103: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
_______________ ERROR collecting test_working_module_doctest.py ________________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_working_module_doctest.py - TypeError: import_path() missing 1 req...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
________________________ test_working_function_doctest _________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_working_function_doctest0')>

    def test_working_function_doctest(testdir: Testdir) -> None:
        testdir.makepyfile(
            textwrap.dedent(
                """
            # simple comment
            GLOBAL_VAR = True

            def func():
                '''
                .. testcode::

                    print(2+5)

                .. testoutput::

                    7
                '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 1 passed in *"])
E       Failed: nomatch: '*=== 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_function_doctest0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '______________ ERROR collecting test_working_function_doctest.py _______________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_working_function_doctest.py - TypeError: import_path() missing 1 r...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 1 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:128: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_function_doctest0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
______________ ERROR collecting test_working_function_doctest.py _______________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_working_function_doctest.py - TypeError: import_path() missing 1 r...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
_____________________ test_working_module_doctest_nospaces _____________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest_nospaces0')>

    def test_working_module_doctest_nospaces(testdir: Testdir) -> None:

        testdir.makepyfile(
            textwrap.dedent(
                """
            '''
            .. testcode::
                print(2+5)

            .. testoutput::
                7
            '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 1 passed in *"])
E       Failed: nomatch: '*=== 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest_nospaces0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '___________ ERROR collecting test_working_module_doctest_nospaces.py ___________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_working_module_doctest_nospaces.py - TypeError: import_path() miss...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 1 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:148: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_working_module_doctest_nospaces0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
___________ ERROR collecting test_working_module_doctest_nospaces.py ___________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_working_module_doctest_nospaces.py - TypeError: import_path() miss...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
____________________ test_multiple_doctests_in_single_file _____________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_multiple_doctests_in_single_file0')>

    def test_multiple_doctests_in_single_file(testdir: Testdir) -> None:

        testdir.makepyfile(
            textwrap.dedent(
                """
            def foo():
                \"\"\"
                .. testcode::

                    print('1adlfadsf')

                .. testoutput::

                    1...
                \"\"\"
                pass

            def bar():
                \"\"\"
                .. testcode::

                    print('1adlfadsf')

                .. testoutput::

                    1...
                \"\"\"
                pass
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 2 passed in *"])
E       Failed: nomatch: '*=== 2 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_multiple_doctests_in_single_file0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '__________ ERROR collecting test_multiple_doctests_in_single_file.py ___________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_multiple_doctests_in_single_file.py - TypeError: import_path() mis...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 2 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:184: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_multiple_doctests_in_single_file0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
__________ ERROR collecting test_multiple_doctests_in_single_file.py ___________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_multiple_doctests_in_single_file.py - TypeError: import_path() mis...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
________________________________ test_indented _________________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_indented0')>

    def test_indented(testdir: Testdir) -> None:
        testdir.makepyfile(
            textwrap.dedent(
                """
        '''
        Examples:
            some text

            .. testcode::

                print("Banana")

            .. testoutput::

                Banana
        '''
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 1 passed in *"])
E       Failed: nomatch: '*=== 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_indented0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '______________________ ERROR collecting test_indented.py _______________________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_indented.py - TypeError: import_path() missing 1 required keyword-...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 1 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:208: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_indented0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
______________________ ERROR collecting test_indented.py _______________________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_indented.py - TypeError: import_path() missing 1 required keyword-...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
___________________ test_workaround_for_doctest_mockobj_bug ____________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_workaround_for_doctest_mockobj_bug0')>

    def test_workaround_for_doctest_mockobj_bug(testdir: Testdir) -> None:
        # see https://github.com/pytest-dev/pytest/issues/3456

        testdir.makepyfile(
            textwrap.dedent(
                """
            \"\"\"
            .. testcode::

                print("Banana")

            .. testoutput::

                Banana

            \"\"\"

            from unittest.mock import call
        """
            )
        )

        result = testdir.runpytest("--doctest-modules")
>       result.stdout.fnmatch_lines(["*=== 1 passed in *"])
E       Failed: nomatch: '*=== 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_workaround_for_doctest_mockobj_bug0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 0 items / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '_________ ERROR collecting test_workaround_for_doctest_mockobj_bug.py __________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect'
E           and: '    module = import_path(self.path, root=self.config.rootpath)'
E           and: "E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR test_workaround_for_doctest_mockobj_bug.py - TypeError: import_path() m...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.11s ==============================='
E       remains unmatched: '*=== 1 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:234: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_workaround_for_doctest_mockobj_bug0
plugins: sphinx-0.6.0
collected 0 items / 1 error

==================================== ERRORS ====================================
_________ ERROR collecting test_workaround_for_doctest_mockobj_bug.py __________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR test_workaround_for_doctest_mockobj_bug.py - TypeError: import_path() m...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.11s ===============================
______________________________ test_with_conftest ______________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-54/test_with_conftest0')>

    def test_with_conftest(testdir: Testdir) -> None:
        content = """
            \"\"\"
            .. testcode::

                print('abc')

            .. testoutput::

                abc
            \"\"\"
        """

        testdir.maketxtfile(test_something=content)

        testdir.makeconftest(content)

        # what do we expect?
        result = testdir.runpytest("--doctest-modules")
        # 2 test passed one test in conftest.py and one in something.py
>       result.stdout.fnmatch_lines(["*=== 2 passed in *"])
E       Failed: nomatch: '*=== 2 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0'
E           and: 'rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_with_conftest0'
E           and: 'plugins: sphinx-0.6.0'
E           and: 'collected 1 item / 1 error'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '_________________________ ERROR collecting conftest.py _________________________'
E           and: '/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:560: in collect'
E           and: '    module = self.config.pluginmanager._importconftest('
E           and: "E   TypeError: _importconftest() missing 1 required keyword-only argument: 'consider_namespace_packages'"
E           and: '=========================== short test summary info ============================'
E           and: 'ERROR conftest.py - TypeError: _importconftest() missing 1 required keyword-o...'
E           and: '!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!'
E           and: '=============================== 1 error in 0.08s ==============================='
E       remains unmatched: '*=== 2 passed in *'

/home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.0/tests/test_python_files.py:257: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-tkloczko/pytest-54/test_with_conftest0
plugins: sphinx-0.6.0
collected 1 item / 1 error

==================================== ERRORS ====================================
_________________________ ERROR collecting conftest.py _________________________
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-sphinx-0.6.0-2.fc36.x86_64/usr/lib/python3.9/site-packages/pytest_sphinx.py:560: in collect
    module = self.config.pluginmanager._importconftest(
E   TypeError: _importconftest() missing 1 required keyword-only argument: 'consider_namespace_packages'
=========================== short test summary info ============================
ERROR conftest.py - TypeError: _importconftest() missing 1 required keyword-o...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
=========================== short test summary info ============================
FAILED tests/test_python_files.py::test_syntax_error_in_module_doctest - Fail...
FAILED tests/test_python_files.py::test_failing_module_doctest - AssertionErr...
FAILED tests/test_python_files.py::test_failing_function_doctest - AssertionE...
FAILED tests/test_python_files.py::test_working_module_doctest - Failed: noma...
FAILED tests/test_python_files.py::test_working_function_doctest - Failed: no...
FAILED tests/test_python_files.py::test_working_module_doctest_nospaces - Fai...
FAILED tests/test_python_files.py::test_multiple_doctests_in_single_file - Fa...
FAILED tests/test_python_files.py::test_indented - Failed: nomatch: '*=== 1 p...
FAILED tests/test_python_files.py::test_workaround_for_doctest_mockobj_bug - ...
FAILED tests/test_python_files.py::test_with_conftest - Failed: nomatch: '*==...
======================== 10 failed, 41 passed in 16.48s ========================
List of installed modules in build env:
Package                       Version
----------------------------- -----------
alabaster                     0.7.16
Babel                         2.14.0
build                         1.1.1
charset-normalizer            3.3.2
distro                        1.9.0
dnf                           4.19.0
docutils                      0.20.1
exceptiongroup                1.1.3
gpg                           1.23.2
idna                          3.6
imagesize                     1.4.1
importlib_metadata            7.0.1
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.3
libdnf                        0.73.0
MarkupSafe                    2.1.3
packaging                     24.0
pluggy                        1.4.0
Pygments                      2.17.2
pyproject_hooks               1.0.0
pytest                        8.1.1
python-dateutil               2.9.0.post0
requests                      2.31.0
setuptools                    69.1.1
snowballstemmer               2.2.0
Sphinx                        7.2.6
sphinxcontrib-applehelp       1.0.8
sphinxcontrib-devhelp         1.0.5
sphinxcontrib-htmlhelp        2.0.5
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.7
sphinxcontrib-serializinghtml 1.1.10
tokenize_rt                   5.2.0
tomli                         2.0.1
urllib3                       1.26.18
wheel                         0.42.0
zipp                          3.17.0

Please let me know if you need more details or want me to perform some diagnostics.

@twmr
Copy link
Owner

twmr commented Mar 11, 2024

Thx for the report! Let me work on a fix.

@twmr
Copy link
Owner

twmr commented Mar 11, 2024

Let's see if this regression in pytest-8.1.1 will be fixed or if pytest plugins have to be adapted.

pytest-dev/pytest#11475 (comment)

@kloczek
Copy link
Author

kloczek commented Mar 11, 2024

Thx for update 👍

@jab
Copy link

jab commented Apr 1, 2024

From pytest-dev/pytest#11475 it looks like the issue here is that pytest 8.1.0 broke this (and other) pytest plugins, and it has not been fixed in pytest 8.1.1.

The telltale error this results in will look something like

_____________________________________________________________ ERROR collecting docs/__init__.py ______________________________________________________________
.venv/lib/python3.12/site-packages/pytest_sphinx.py:567: in collect
    module = import_path(self.path, root=self.config.rootpath)
E   TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages'

This issue title and description should ideally be updated as per the above, to make it easier for other users who hit this to realize this is the issue to watch. The current issue title and description make this really unclear.

Also looks like pytest-dev/pytest#11475 has been closed for a while with no new activity, and pytest 8.1.1 has since come out without fixing this.

jab added a commit to jab/bidict that referenced this issue Apr 1, 2024
Mainly hypothesis. Hold back on updating to pytest 8.1.1
since it broke pytest-sphinx, and a compatible version of pytest-sphinx
has not come out yet. Ref: twmr/pytest-sphinx#62
@twmr
Copy link
Owner

twmr commented Apr 1, 2024

This should be fixed in v0.6.2. @kloczek can you please try to package pytest-sphinx again? Thx

@jab thx for informing me that this GH issue was not yet solved. Now that it is solved, I don't think that we need to clean up the title/description of this GH issue.

@kloczek
Copy link
Author

kloczek commented Apr 1, 2024

Just tested 0.6.2 and looks like all is clan now 😄

==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-sphinx-0.6.2
configfile: pyproject.toml
plugins: sphinx-0.6.2, benchmark-4.0.0
collected 51 items

tests/test_doc2test.py .....                                                                                                                                                          [  9%]
tests/test_options.py ..........                                                                                                                                                      [ 29%]
tests/test_python_files.py ..........                                                                                                                                                 [ 49%]
tests/test_sphinx_doctest.py ................                                                                                                                                         [ 80%]
tests/test_text_files.py ..........                                                                                                                                                   [100%]

==================================================================================== 51 passed in 18.13s ====================================================================================

Thank you and closing 👍

@kloczek kloczek closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants