Pytest does not find my tests in Poetry project (VSCode finds)
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:
- With my venv manually activated:
pytest
pytest tests
pytest tests/test_mypackage.py
cd tests;pytest test_mypackage.py
- without my venv activated:
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?
do you know?
how many words do you know