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

22.9.1: pytest is failing in pydoctor/test/test_cyclic_imports_base_classes.py::test_cyclic_imports_base_classes unit #670

Closed
kloczek opened this issue Dec 8, 2022 · 15 comments

Comments

@kloczek
Copy link

kloczek commented Dec 8, 2022

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>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Looks like one unit cannot find pydoctor 🤔
Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pydoctor-22.9.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pydoctor-22.9.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pydoctor-22.9.1, configfile: setup.cfg, testpaths: pydoctor/test
plugins: hypothesis-6.60.0
collected 1126 items

pydoctor/test/test_astbuilder.py ................................................................................................................................... [ 11%]
.................................................................................................................................................................... [ 26%]
.................................................................................................................................................................... [ 40%]
.................................................................................................................................................................... [ 55%]
.............                                                                                                                                                        [ 56%]
pydoctor/test/test_attrs.py ..........                                                                                                                               [ 57%]
pydoctor/test/test_colorize.py .....                                                                                                                                 [ 57%]
pydoctor/test/test_commandline.py ...................                                                                                                                [ 59%]
pydoctor/test/test_configparser.py ......                                                                                                                            [ 60%]
pydoctor/test/test_cyclic_imports_base_classes.py F                                                                                                                  [ 60%]
pydoctor/test/test_epydoc2stan.py ........xxx.........................................................                                                               [ 66%]
pydoctor/test/test_model.py ..............s......                                                                                                                    [ 68%]
pydoctor/test/test_mro.py ..........                                                                                                                                 [ 68%]
pydoctor/test/test_napoleon_docstring.py .......................................................                                                                     [ 73%]
pydoctor/test/test_napoleon_iterators.py .................                                                                                                           [ 75%]
pydoctor/test/test_node2stan.py ..                                                                                                                                   [ 75%]
pydoctor/test/test_options.py ..........                                                                                                                             [ 76%]
pydoctor/test/test_packages.py ............                                                                                                                          [ 77%]
pydoctor/test/test_pydantic_fields.py ..                                                                                                                             [ 77%]
pydoctor/test/test_qnmatch.py ......                                                                                                                                 [ 78%]
pydoctor/test/test_sphinx.py .............................                                                                                                           [ 80%]
pydoctor/test/test_templatewriter.py .....................................                                                                                           [ 84%]
pydoctor/test/test_twisted_python_deprecate.py ........                                                                                                              [ 84%]
pydoctor/test/test_type_fields.py ..........                                                                                                                         [ 85%]
pydoctor/test/test_utils.py ...............                                                                                                                          [ 86%]
pydoctor/test/test_visitor.py ..                                                                                                                                     [ 87%]
pydoctor/test/test_zopeinterface.py ....................................................                                                                             [ 91%]
pydoctor/test/epydoc/epytext.doctest .                                                                                                                               [ 91%]
pydoctor/test/epydoc/restructuredtext.doctest .                                                                                                                      [ 91%]
pydoctor/test/epydoc/test_epytext.py ....                                                                                                                            [ 92%]
pydoctor/test/epydoc/test_epytext2html.py ...........                                                                                                                [ 93%]
pydoctor/test/epydoc/test_epytext2node.py .                                                                                                                          [ 93%]
pydoctor/test/epydoc/test_google_numpy.py .....                                                                                                                      [ 93%]
pydoctor/test/epydoc/test_parsed_docstrings.py .                                                                                                                     [ 93%]
pydoctor/test/epydoc/test_pyval_repr.py ...................................................                                                                          [ 98%]
pydoctor/test/epydoc/test_restructuredtext.py ..................                                                                                                     [100%]

================================================================================= FAILURES =================================================================================
_____________________________________________________________________ test_cyclic_imports_base_classes _____________________________________________________________________

    def test_cyclic_imports_base_classes() -> None:
        if sys.platform == 'win32':
            # Running this script with the following subprocess call fails on Windows
            # with an ImportError that isn't actually related to what we want to test.
            # So we just skip for Windows.
            return

        process = subprocess.Popen(
            [sys.executable, os.path.basename(__file__)],
            env={'PYTHONHASHSEED': '0'},
            cwd=os.path.dirname(__file__),
        )
>       assert process.wait() == 0
E       assert 1 == 0
E        +  where 1 = <bound method Popen.wait of <subprocess.Popen object at 0x7f7500bbf0d0>>()
E        +    where <bound method Popen.wait of <subprocess.Popen object at 0x7f7500bbf0d0>> = <subprocess.Popen object at 0x7f7500bbf0d0>.wait

pydoctor/test/test_cyclic_imports_base_classes.py:22: AssertionError
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
Traceback (most recent call last):
  File "test_cyclic_imports_base_classes.py", line 26, in <module>
    from test_packages import processPackage, model # type: ignore
  File "/home/tkloczko/rpmbuild/BUILD/pydoctor-22.9.1/pydoctor/test/test_packages.py", line 5, in <module>
    from pydoctor import model
ModuleNotFoundError: No module named 'pydoctor'
========================================================================= short test summary info ==========================================================================
SKIPPED [1] pydoctor/test/test_model.py:293: cython_test_exception_raiser not installed
XFAIL pydoctor/test/test_epydoc2stan.py::test_func_arg_and_ret_annotation
XFAIL pydoctor/test/test_epydoc2stan.py::test_func_arg_and_ret_annotation_with_override
XFAIL pydoctor/test/test_epydoc2stan.py::test_func_arg_when_doc_missing
FAILED pydoctor/test/test_cyclic_imports_base_classes.py::test_cyclic_imports_base_classes - assert 1 == 0
========================================================== 1 failed, 1121 passed, 1 skipped, 3 xfailed in 24.44s ===========================================================

Here is list of installed modules in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
appdirs                       1.4.4
astor                         0.8.1
attrs                         22.1.0
Automat                       20.2.0
Babel                         2.11.0
beautifulsoup4                4.11.1
Brlapi                        0.8.3
build                         0.9.0
CacheControl                  0.12.11
charset-normalizer            3.0.1
ConfigArgParse                1.5.3
constantly                    15.1.0
contourpy                     1.0.6
cssselect                     1.1.0
cycler                        0.11.0
distro                        1.8.0
dnspython                     2.2.1
docutils                      0.19
exceptiongroup                1.0.0
extras                        1.0.0
fixtures                      4.0.0
fonttools                     4.38.0
gpg                           1.17.1-unknown
hyperlink                     21.0.0
hypothesis                    6.60.0
idna                          3.4
imagesize                     1.4.1
importlib-metadata            5.1.0
importlib-resources           5.10.1
incremental                   21.3.0
iniconfig                     1.1.1
Jinja2                        3.1.2
kiwisolver                    1.4.4
libcomps                      0.1.19
lockfile                      0.12.2
louis                         3.24.0
lunr                          0.6.2
lxml                          4.9.1
MarkupSafe                    2.1.1
matplotlib                    3.6.2
msgpack                       1.0.4
natsort                       8.0.2
numpy                         1.23.1
olefile                       0.46
packaging                     21.3
pbr                           5.9.0
pep517                        0.13.0
Pillow                        9.3.0
pip                           22.3.1
pluggy                        1.0.0
pyenchant                     3.2.2
Pygments                      2.13.0
PyGObject                     3.42.2
pyparsing                     3.0.9
pytest                        7.2.0
python-dateutil               2.8.2
pytz                          2022.4
requests                      2.28.1
rpm                           4.17.0
scour                         0.38.2
setuptools                    65.6.3
six                           1.16.0
snowballstemmer               2.2.0
sortedcontainers              2.4.0
soupsieve                     2.3.2.post1
Sphinx                        5.3.0
sphinx-argparse               0.4.0
sphinx-rtd-theme              1.1.1
sphinxcontrib-applehelp       1.0.2.dev20221204
sphinxcontrib-devhelp         1.0.2.dev20221204
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20221204
sphinxcontrib-qthelp          1.0.3.dev20221204
sphinxcontrib-serializinghtml 1.1.5
sphinxcontrib-spelling        7.6.0
sre-parse36                   1.0.0
testtools                     2.5.0
toml                          0.10.2
tomli                         2.0.1
Twisted                       22.10.0
typing_extensions             4.4.0
urllib3                       1.26.12
wheel                         0.38.4
zipp                          3.11.0
zope.event                    4.5.0
zope.interface                5.5.2
@tristanlatr
Copy link
Contributor

Hi,

Looks like you have already opened an issue about this: #556.

Since the test is successful in our CI, I don't know what to say other than to make importable the pydoctor module in your CI environment or deselect the test.

@kloczek
Copy link
Author

kloczek commented Dec 8, 2022

Hi,

Looks like you have already opened an issue about this: #556.

Since the test is successful in our CI, I don't know what to say other than to make importable the pydoctor module in your CI environment or deselect the test.

Did you try to reporoduce that issue using described method?
Why only this one unit cannot find pydoctor? 🤔

@tristanlatr
Copy link
Contributor

No I haven’t reproduced the error. And it’s not really an issue in my perspective since the test passes in our CI.

The error your facing most probably reside in the fact that you rely on custom PYTHONPATH instead of using the default. That environment variable does not get passed to the sub process running this test, so it can’t find the module.

@kloczek
Copy link
Author

kloczek commented Dec 9, 2022

The error your facing most probably reside in the fact that you rely on custom PYTHONPATH instead of using the default. That environment variable does not get passed to the sub process running this test, so it can’t find the module.

So how to pass it? 🤔
That procedure with altering $PYTHONPATH is widely used on packaging python modules from non-root account.
Example from Fedora https://src.fedoraproject.org/rpms/python-rpm-macros/blob/rawhide/f/macros.python3#_110
The same is used in Debian.

@tristanlatr
Copy link
Contributor

So how to pass it?

Two solutions: 1. You deselect the test and we don’t talk about it anymore, cause after all it’s not an issue with the software. 2. You patch the test so it passes on your environment by passing along the environment variable PYTHONPATH to the subprocess.

@kloczek
Copy link
Author

kloczek commented Jan 21, 2023

Hmm .. issue has been resolved? 🤔

@tristanlatr
Copy link
Contributor

This test is correctly running in our CI, so it's not an issue IMO.

If you like to submit a PR that fixes your problem, I'll have a look :)

@kloczek
Copy link
Author

kloczek commented Jan 21, 2023

Did you had a look at least on list of modules with versions which I've used?
Did you try to reproduce that in the same env?
To submit PR first you need to know the cause.

@tristanlatr
Copy link
Contributor

No.

If YOU want to contribute, please go ahead. I’m not interested into fixing this issue.

@kloczek
Copy link
Author

kloczek commented Jan 21, 2023

So what kind of issue is here? 🤔

@tristanlatr
Copy link
Contributor

It’s an issue with your environment. We already talked about that.

@kloczek
Copy link
Author

kloczek commented Jan 21, 2023

Only now you've mentioned about issue with my env and still you did not shared details about what you've found.
Could you please share what you've found?

@tristanlatr
Copy link
Contributor

I did not found more information.

Here is what I suggest you to do:
Patch the test so it passes on your environment by passing along the environment variable PYTHONPATH to the subprocess.

@kloczek
Copy link
Author

kloczek commented Jan 21, 2023

Again .. it is really not possible to patch anything if it is unknown cause and you are not even trying to help understand what could be the cause.
Your commenets are as well contradicting. One time you are claiming that there is no issue other time that it is the issue.
Please ..

@tristanlatr
Copy link
Contributor

If you don’t want to understand what I’m saying it’s your problem. I’m not going to spend more time answering your non-constructive messages. We’re done here.

@twisted twisted locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants