I've just created my first Python package using Poetry using the usual poetry new mypackage
command. My problem is that pytest
does not execute any test when I run it. I'm developing using VSCode and the weird behavior is that VSCode successfully finds and executes my tests.
Poetry created a subdir called mypackage
and another called tests
. My test file is called tests/test_mypackage.py
.
VSCode autodiscoverd the tests, and display them in the test tab. The .vscode/settings.json
file has this configuration:
"python.testing.pytestArgs": [
"tests"
],
I've tried the following commands to execute pytest:
pytest
pytest tests
pytest tests/test_mypackage.py
cd tests;pytest test_mypackage.py
poetry run pytest
poetry run pytest tests
The behavior is always the same: nothing happens, as if pytest couldn't detect anything to run.
I've been using VSCode to run the tests, but now I want to put the code under Continuous Integration. How do I run pytest to validate my package?
UPDATE: from inside the virtual env pytest does not prints any output when run, but its return code is 1.
pytest
still does not work when running within the activated virtual environment, but I discovered that I can execute it running:
poetry run pytest
I still do not understand why it can't find the test when directly run from the command line even with the venv activated.