В каталоге root, но pytest не запускает тесты независимо от того, какая команда запущена (py.test, pytest, python3 -m pytest ...)
На основании других сообщений здесь у меня есть следовал всем этим советам:
- Убедитесь, что все файлы с тестовыми примерами начинаются со слова 'test_'.
- Убедитесь, что все имена тестовых примеров также начинаются со слова 'test_'.
- Убедитесь, что вы создали файл pytest.ini в каталоге root
- Убедитесь, что у вас есть файл init .py во всех каталогах / подкаталогах проекта
Каталог файлов:
.
├── Procfile
├── __pycache__
├── config.py
├── learning_flashcards
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── app.cpython-36.pyc
│ │ ├── models.cpython-36.pyc
│ │ └── views.cpython-36.pyc
│ ├── app.py
│ ├── db.py
│ ├── models.py
│ ├── static
│ │ └── style.css
│ ├── templates
│ └── views.py
├── learning_flashcards.egg-info
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ ├── dependency_links.txt
│ ├── requires.txt
│ └── top_level.txt
├── manage.py
├── migrations
│ ├── README
│ ├── alembic.ini
│ ├── env.py
│ ├── script.py.mako
│ └── versions
├── pytest.ini
├── requirements
│ ├── common.txt
│ ├── dev.txt
│ └── runtime.txt
├── requirements.txt
├── setup.py
├── tests
│ ├── [pytest]
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── conftest.cpython-36-pytest-5.4.3.pyc
│ │ ├── test_data.cpython-36-pytest-5.4.3.pyc
│ │ └── test_site.cpython-36-pytest-5.4.3.pyc
│ ├── conftest.py
│ ├── test_data.py
│ └── test_site.py
└── venv
Тестовый файл test_site.py:
import pytest
from learning_flashcards.app import create_app
@pytest.fixture(autouse=True)
def test_site(app):
assert app.get(url_for('/')).status_code == 200
Contest.py:
import pytest
from learning_flashcards.app import create_app
@pytest.fixture
def app():
app = create_app()
return app
pytest .ini:
[pytest]
minversion = 5.4.3
testpath = tests
Я никогда раньше не использовал pytest, поэтому мой подход может быть неправильным.