Skip to content

1.10: pytest is failing #34

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

Closed
kloczek opened this issue Sep 6, 2021 · 2 comments
Closed

1.10: pytest is failing #34

kloczek opened this issue Sep 6, 2021 · 2 comments

Comments

@kloczek
Copy link

kloczek commented Sep 6, 2021

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

  • "setup.py build"
  • "setup.py install --root </install/prefix>"
  • "pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (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)
Using --randomly-seed=2477080430
rootdir: /home/tkloczko/rpmbuild/BUILD/async_generator-1.10
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3
collected 0 items / 1 error

================================================================================== ERRORS ==================================================================================
______________________________________________________________________ ERROR collecting test session _______________________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/config/__init__.py:570: in _importconftest
    mod = import_path(conftestpath, mode=importmode)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:544: in import_path
    raise ImportPathMismatchError(module_name, module_file, path)
E   _pytest.pathlib.ImportPathMismatchError: ('async_generator._tests.conftest', '/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/lib/python3.8/site-packages/async_generator/_tests/conftest.py', PosixPath('/home/tkloczko/rpmbuild/BUILD/async_generator-1.10/async_generator/_tests/conftest.py'))
========================================================================= short test summary info ==========================================================================
ERROR  - _pytest.pathlib.ImportPathMismatchError: ('async_generator._tests.conftest', '/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/l...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.40s =============================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

and the same but with --import-mode=importlib

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-async-generator-1.10-12.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --import-mode=importlib
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (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)
Using --randomly-seed=1808263463
rootdir: /home/tkloczko/rpmbuild/BUILD/async_generator-1.10
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3
collected 0 items / 2 errors

================================================================================== ERRORS ==================================================================================
_____________________________________________________ ERROR collecting async_generator/_tests/test_async_generator.py ______________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/async_generator-1.10/async_generator/_tests/test_async_generator.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
async_generator/_tests/test_async_generator.py:9: in <module>
    from .conftest import mock_sleep
E   ImportError: attempted relative import with no known parent package
___________________________________________________________ ERROR collecting async_generator/_tests/test_util.py ___________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/async_generator-1.10/async_generator/_tests/test_util.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
async_generator/_tests/test_util.py:3: in <module>
    from .. import aclosing, async_generator, yield_, asynccontextmanager
E   ImportError: attempted relative import with no known parent package
========================================================================= short test summary info ==========================================================================
ERROR async_generator/_tests/test_async_generator.py
ERROR async_generator/_tests/test_util.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================ 2 errors in 0.40s =============================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
@njsmith
Copy link
Member

njsmith commented Sep 7, 2021

This is some kind of problem with how you're invoking pytest -- it's going into the mode where it tries to find individual test modules, instead of the mode where it imports a whole test package. I always find this part of pytest super confusing, and I don't know how to fix it off-hand. Maybe try passing --pyargs async_generator?

@kloczek
Copy link
Author

kloczek commented Sep 7, 2021

Yep that works. Just learn something new :)

+ /usr/bin/pytest -ra --pyargs async_generator
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (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)
Using --randomly-seed=1465983438
rootdir: /home/tkloczko/rpmbuild/BUILD/async_generator-1.10
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3
collected 43 items

_tests/test_async_generator.py .................................                                                                                                     [ 76%]
_tests/test_util.py ..........                                                                                                                                       [100%]

============================================================================ 43 passed in 1.51s ============================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

Thank you and closing :)

@kloczek kloczek closed this as completed Sep 7, 2021
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

2 participants