Вот мой настройка:
Код: Выделить всё
conftest.pyКод: Выделить всё
import pytest
def pytest_configure(config):
config.addinivalue_line("markers", "variant: mark test to run only for specific variants")
config.addinivalue_line("markers", "do_not_dismiss_language_selector: mark test to skip dismissing the language selector after setup")
def pytest_collection_modifyitems(config, items):
options = get_options(config)
selected_items = filter_items(items, options)
deselected_items = [item for item in items if item not in selected_items]
if deselected_items:
config.hook.pytest_deselected(items=deselected_items)
items[:] = selected_items
Код: Выделить всё
pyproject.tomlКод: Выделить всё
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --strict-markers"
markers = [
"variant: mark test to run only for specific variants",
"do_not_dismiss_language_selector: mark test to skip dismissing the language selector after setup"
]
Код: Выделить всё
import pytest
@pytest.mark. # Autocomplete only shows default Pytest markers, not my custom ones
- Проверено с помощью pytest --markers: все пользовательские маркеры отображаются, поэтому pytest распознает их правильно.
- Перезапуск PyCharm: после каждого изменения в conftest.py и pyproject.toml, я аннулировал кеши и перезапустил PyCharm.
- Проверил интерпретатор Python: убедился, что PyCharm использует правильный виртуальной среде.
- Протестировано как в pytest.ini, так и в pyproject.toml: я попробовал определить маркеры в обеих конфигурациях, чтобы проверить, один будет работать лучше.
- Создал новый тестовый файл: я создал новый тестовый файл, чтобы проверить, распознает ли PyCharm имеющиеся там маркеры, но он этого не сделал. .
- Версия PyCharm: 2024.1.7
- Версия Python: 3.10
Версия Pytest: 7.4.4< /li>
Подробнее здесь: https://stackoverflow.com/questions/791 ... o-complete
Мобильная версия