sphinx-contrib / sphinx-contrib/autoprogram

0.1.8: pytest is failing with ` module 'autoprogram' has no attribute 'add_directive'`

Open
#65 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
48
Forks
24
Avg merge
2h 15m
Merged PRs (30d)
1

Description

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-sphinxcontrib-autoprogram-0.1.8-3.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-autoprogram-0.1.8-3.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' sphinxcontrib/autoprogram.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.17, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8
collected 8 items

sphinxcontrib/autoprogram.py EEEEEEEE                                                                                                                                                 [100%]

========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________ ERROR at setup of ScannerTestCase.test_argument_groups ___________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
______________________________________________________________________ ERROR at setup of ScannerTestCase.test_choices _______________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
____________________________________________________________________ ERROR at setup of ScannerTestCase.test_parse_epilog ____________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
___________________________________________________________________ ERROR at setup of ScannerTestCase.test_simple_parser ____________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
____________________________________________________________________ ERROR at setup of ScannerTestCase.test_subcommands _____________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
_______________________________________________________________ ERROR at setup of AutoprogramDirectiveTestCase.test_make_rst ________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
_____________________________________________________________________ ERROR at setup of UtilTestCase.test_import_object _____________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
______________________________________________________________________ ERROR at setup of test_case.test_import_object _______________________________________________________________________

app = <module 'autoprogram' from '/home/tkloczko/rpmbuild/BUILD/autoprogram-0.1.8/sphinxcontrib/autoprogram.py'>

    def setup(app) -> Dict[str, bool]:
>       app.add_directive("autoprogram", AutoprogramDirective)
E       AttributeError: module 'autoprogram' has no attribute 'add_directive'

sphinxcontrib/autoprogram.py:338: AttributeError
================================================================================== short test summary info ==================================================================================
ERROR sphinxcontrib/autoprogram.py::ScannerTestCase::test_argument_groups - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::ScannerTestCase::test_choices - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::ScannerTestCase::test_parse_epilog - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::ScannerTestCase::test_simple_parser - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::ScannerTestCase::test_subcommands - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::AutoprogramDirectiveTestCase::test_make_rst - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::UtilTestCase::test_import_object - AttributeError: module 'autoprogram' has no attribute 'add_directive'
ERROR sphinxcontrib/autoprogram.py::test_case::test_import_object - AttributeError: module 'autoprogram' has no attribute 'add_directive'
===================================================================================== 8 errors in 0.31s =====================================================================================

Here is list of installed modules in build env

Package                       Version
----------------------------- -------
alabaster                     0.7.13
Babel                         2.12.1
build                         0.10.0
charset-normalizer            3.2.0
distro                        1.8.0
docutils                      0.19
exceptiongroup                1.1.1
gpg                           1.20.0
idna                          3.4
imagesize                     1.4.1
importlib-metadata            6.8.0
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.2
libcomps                      0.1.19
MarkupSafe                    2.1.2
packaging                     23.1
pluggy                        1.2.0
Pygments                      2.16.0
pyproject_hooks               1.0.0
pytest                        7.4.0
python-dateutil               2.8.2
pytz                          2023.2
requests                      2.31.0
setuptools                    68.0.0
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        6.2.1
sphinxcontrib-applehelp       1.0.4
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
tomli                         2.0.1
urllib3                       1.26.15
wheel                         0.40.0
zipp                          3.16.2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sphinxcontrib/autoprogram.py, especially setup at line 338, and reproduce the failure using the reported PEP517 build, installation, PYTHONPATH, and pytest command. Trace why the test fixture receives the autoprogram module instead of an object with add_directive; done means the eight reported tests pass in the described offline environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, documentation, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.