8.11.1: pytest fails
Nobody has claimed this yet.
- #783 by @kloczek — closed without merging
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 815
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 2
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
buildwith--no-isolationI'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-twilio-8.11.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-twilio-8.11.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.18, pytest-7.4.4, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/twilio-python-8.11.1
collected 537 items / 2 errors
========================================================================================== ERRORS ===========================================================================================
______________________________________________________________________ ERROR collecting tests/cluster/test_webhook.py _______________________________________________________________________
tests/cluster/test_webhook.py:7: in <module>
class RequestHandler(BaseHTTPRequestHandler):
tests/cluster/test_webhook.py:9: in RequestHandler
validator = RequestValidator(os.environ["TWILIO_AUTH_TOKEN"])
/usr/lib64/python3.8/os.py:675: in __getitem__
raise KeyError(key) from None
E KeyError: 'TWILIO_AUTH_TOKEN'
_________________________________________________________________ ERROR collecting twilio/rest/events/v1/sink/sink_test.py __________________________________________________________________
import file mismatch:
imported module 'twilio.rest.events.v1.sink.sink_test' has this __file__ attribute:
/home/tkloczko/rpmbuild/BUILDROOT/python-twilio-8.11.1-2.fc35.x86_64/usr/lib/python3.8/site-packages/twilio/rest/events/v1/sink/sink_test.py
which is not the same as the test file we want to collect:
/home/tkloczko/rpmbuild/BUILD/twilio-python-8.11.1/twilio/rest/events/v1/sink/sink_test.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
===================================================================================== warnings summary ======================================================================================
tests/unit/base/test_version.py:7
/home/tkloczko/rpmbuild/BUILD/twilio-python-8.11.1/tests/unit/base/test_version.py:7: PytestCollectionWarning: cannot collect test class 'TestPage' because it has a __init__ constructor (from: tests/unit/base/test_version.py)
class TestPage(Page):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
ERROR tests/cluster/test_webhook.py - KeyError: 'TWILIO_AUTH_TOKEN'
ERROR twilio/rest/events/v1/sink/sink_test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================== 1 warning, 2 errors in 1.20s ================================================================================
List of installed modules in build env:
Package Version
----------------------------- -------
aiohttp 3.9.1
aiohttp-retry 2.8.3
aiosignal 1.3.1
aiounittest 1.4.2
alabaster 0.7.16
asgiref 3.7.2
async-timeout 4.0.3
attrs 23.2.0
Babel 2.14.0
backports.zoneinfo 0.2.1
build 1.0.3
cffi 1.16.0
charset-normalizer 3.3.2
commonmark 0.9.1
cppclean 0.13
cryptography 41.0.5
distro 1.9.0
Django 4.2.6
dnf 4.18.2
docutils 0.20.1
exceptiongroup 1.1.3
frozenlist 1.4.1
gpg 1.23.2
idna 3.6
imagesize 1.4.1
importlib-metadata 7.0.1
iniconfig 2.0.0
installer 0.7.0
Jinja2 3.1.3
libdnf 0.72.0
MarkupSafe 2.1.3
mock 5.1.0
multidict 6.0.4
packaging 23.2
pluggy 1.3.0
ply 3.11
pycparser 2.21
Pygments 2.17.2
PyJWT 2.8.0
pyngrok 7.0.5
pyproject_hooks 1.0.0
pytest 7.4.4
python-dateutil 2.8.2
pytz 2023.3
PyYAML 6.0.1
recommonmark 0.7.1
requests 2.31.0
setuptools 69.0.3
six 1.16.0
snowballstemmer 2.2.0
Sphinx 7.1.2
sphinxcontrib-applehelp 1.0.4
sphinxcontrib-devhelp 1.0.5
sphinxcontrib-htmlhelp 2.0.4
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.10
sqlparse 0.4.4
tomli 2.0.1
typing_extensions 4.9.0
urllib3 1.26.18
wheel 0.42.0
wrapt 1.16.0
yarl 1.9.2
zipp 3.17.0
Please let me know if you need more details or want me to perform some diagnostics.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PEP517 command and offline pytest invocation described in the issue, then inspect tests/cluster/test_webhook.py and twilio/rest/events/v1/sink/sink_test.py. Reproduce both collection errors using the installed wheel and the source tree on PYTHONPATH. Done means the offline test run collects without the missing environment-variable error or import-file mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100