python-trio / sniffio

Sniff out which async library your code is running under

Home Page:https://sniffio.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.2.0: pytest is failing

kloczek opened this issue · comments

I'm not 100% sure am I testing sniffio correctly :/

Just normal build, install and test cycle used on building package from non-root account:

  • "setup.py build"
  • "setup.py install --root </install/prefix>"
  • "pytest with PYTHONPATH pointing to setearch and sitelib inside </install/prefix>
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sniffio-1.2.0-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sniffio-1.2.0-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, 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)
rootdir: /home/tkloczko/rpmbuild/BUILD/sniffio-1.2.0
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, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, toolbox-0.5, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, 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, hypothesis-6.14.4, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0
collected 2 items / 1 error / 1 selected

================================================================================== ERRORS ==================================================================================
_____________________________________________________________ ERROR collecting sniffio/_tests/test_sniffio.py ______________________________________________________________
import file mismatch:
imported module 'sniffio._tests.test_sniffio' has this __file__ attribute:
  /home/tkloczko/rpmbuild/BUILDROOT/python-sniffio-1.2.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/sniffio/_tests/test_sniffio.py
which is not the same as the test file we want to collect:
  /home/tkloczko/rpmbuild/BUILD/sniffio-1.2.0/sniffio/_tests/test_sniffio.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
========================================================================= short test summary info ==========================================================================
ERROR sniffio/_tests/test_sniffio.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.18s =============================================================================
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()'.

We're unlikely to support running our test suite with this configuration. See the ci/ folder for a way to reproducible run our test suite.

Note that the pytest output:

which is not the same as the test file we want to collect:
  /home/tkloczko/rpmbuild/BUILD/sniffio-1.2.0/sniffio/_tests/test_sniffio.py

...means that the way you're running pytest, you're somehow telling it to test the source files inside your build directory, not the installed package files like you want to. So there's something wrong with your pytest invocation or PYTHONPATH setting.

Lokksl like running with --pyargs sniffio solvet the issue.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sniffio-1.2.0-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sniffio-1.2.0-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --pyargs sniffio
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, 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)
rootdir: /home/tkloczko/rpmbuild/BUILD/sniffio-1.2.0
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, case-1.5.3, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, 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, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0, asyncio-0.15.1, trio-0.7.0, httpbin-1.0.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0
collected 3 items

_tests/test_sniffio.py ...                                                                                                                                           [100%]

============================================================================ 3 passed in 0.13s =============================================================================
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.