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

test failures with pytest7: AttributeError: module 'humanfriendly.tests' has no attribute 'connect' #64

Open
sandrotosi opened this issue Jul 12, 2022 · 0 comments · May be fixed by #65

Comments

@sandrotosi
Copy link

sandrotosi commented Jul 12, 2022

Hello,
in debian we recently started the upgrade to pytest7, and now humanfriendly tests are failing with the error below:

# python3 -m pytest humanfriendly/tests.py::HumanFriendlyTestCase::test_touch --verbose
============================================================================================================================= test session starts ==============================================================================================================================
platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /build/humanfriendly-10.0, configfile: tox.ini
collected 1 item                                                                                                                                                                                                                                                               

humanfriendly/tests.py::HumanFriendlyTestCase::test_touch ERROR                                                                                                                                                                                                          [100%]

======= ERRORS =======
_______ ERROR at setup of HumanFriendlyTestCase.test_touch _______

app = <module 'humanfriendly.tests' from '/build/humanfriendly-10.0/humanfriendly/tests.py'>

    def setup(app):
        """
        Enable all of the provided Sphinx_ customizations.
    
        :param app: The Sphinx application object.
    
        The :func:`setup()` function makes it easy to enable all of the Sphinx
        customizations provided by the :mod:`humanfriendly.sphinx` module with the
        least amount of code. All you need to do is to add the module name to the
        ``extensions`` variable in your ``conf.py`` file:
    
        .. code-block:: python
    
           # Sphinx extension module names.
           extensions = [
               'sphinx.ext.autodoc',
               'sphinx.ext.doctest',
               'sphinx.ext.intersphinx',
               'humanfriendly.sphinx',
           ]
    
        When Sphinx sees the :mod:`humanfriendly.sphinx` name it will import the
        module and call its :func:`setup()` function. This function will then call
        the following:
    
        - :func:`enable_deprecation_notes()`
        - :func:`enable_man_role()`
        - :func:`enable_pypi_role()`
        - :func:`enable_special_methods()`
        - :func:`enable_usage_formatting()`
    
        Of course more functionality may be added at a later stage. If you don't
        like that idea you may be better of calling the individual functions from
        your own ``setup()`` function.
        """
        from humanfriendly import __version__
    
>       enable_deprecation_notes(app)

humanfriendly/sphinx.py:250: 
_ _ _ _ _

app = <module 'humanfriendly.tests' from '/build/humanfriendly-10.0/humanfriendly/tests.py'>

    def enable_deprecation_notes(app):
        """
        Enable documenting backwards compatibility aliases using the autodoc_ extension.
    
        :param app: The Sphinx application object.
    
        This function connects the :func:`deprecation_note_callback()` function to
        ``autodoc-process-docstring`` events.
    
        .. _autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html
        """
>       app.connect("autodoc-process-docstring", deprecation_note_callback)
E       AttributeError: module 'humanfriendly.tests' has no attribute 'connect'

humanfriendly/sphinx.py:112: AttributeError
======= short test summary info =======
ERROR humanfriendly/tests.py::HumanFriendlyTestCase::test_touch - AttributeError: module 'humanfriendly.tests' has no attribute 'connect'
======= 1 error in 0.12s =======

i tried for a while to figure out what's going on but i didnt manage to find the reason: can you help me out? thanks!

please note that running the test suite with pytest 6.2.5, it passes just fine, so it has to be something specific to python 7 (we're using 7.1.2 ftr)

s-t-e-v-e-n-k added a commit to s-t-e-v-e-n-k/python-humanfriendly that referenced this issue Jul 29, 2022
pytest 7 and above will call any setup as a hook for any module
collected, which in this case calls into the Sphinx machinery due to
importing the setup function from there. Import it as something else so
that pytest will not call it.

Fixes xolox#64
@s-t-e-v-e-n-k s-t-e-v-e-n-k linked a pull request Jul 29, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant