-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
28 lines (23 loc) · 881 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
test_executed = False
every_test_skipped = True
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
global every_test_skipped, test_executed
outcome = yield
test_executed = True
rep = outcome.get_result()
if not rep.skipped and rep.when == 'setup':
every_test_skipped = False
@pytest.hookimpl(trylast=True)
def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
try:
# Before pytest 5 the values were contants
from _pytest.main import EXIT_NOTESTSCOLLECTED
no_tests_collected = EXIT_NOTESTSCOLLECTED
except ImportError:
# From pytest 5 on the values are inside an enum
from pytest import ExitCode
no_tests_collected = ExitCode.NO_TESTS_COLLECTED
if test_executed and every_test_skipped:
session.exitstatus = no_tests_collected