summaryrefslogtreecommitdiffstats
path: root/conftest.py
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-08-07 16:59:54 +0300
committerEdi Feschiyan <efeschiyan@pm.me>2020-08-07 16:59:54 +0300
commit4b4deff8e1e27ca99aec41aad3dbd46303792729 (patch)
treedcd5e9cee4815bbd0dad782a6e1bde5ccca850a9 /conftest.py
parent1783f229db62c47e990909bc193cc9bea963ca2f (diff)
Registering "regular" and "hwrequired" test markers, adding them to tests
Enabling custom pytest --lava option for LAVA CI integration Enabling tox for CI bluetooth::default_adapter should support setting a default one according to documentation in README.md
Diffstat (limited to 'conftest.py')
-rw-r--r--conftest.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..2176354
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,32 @@
+import pytest
+
+
+def pytest_addoption(parser):
+ parser.addoption('-L', '--lava', action='store_true', help='enable LAVA signals')
+
+
+def lava_result_convert(pytest_outcome):
+ """ Convert the pytestoutcome to the string expected by LAVA."""
+ if pytest_outcome == 'passed':
+ return 'pass'
+ elif pytest_outcome == 'skipped':
+ return 'pass'
+ elif pytest_outcome == 'xfailed':
+ return 'pass'
+ else:
+ return'fail'
+
+
+def pytest_report_teststatus(config, report):
+ """ Insert strings that LAVA expects to capture test results."""
+# Get pytest test name and remove the 'test_' prefix
+ if config.getoption('--lava'):
+ test_name = report.location[2][5:]
+ if report.when == 'setup':
+ print('\n')
+ print(f'<LAVA_SIGNAL_STARTTC {test_name}>')
+ elif report.when == 'call':
+ test_result = lava_result_convert(report.outcome)
+ print('\n')
+ print(f'<LAVA_SIGNAL_ENDTC {test_name}>')
+ print(f'<LAVA_SIGNAL_TESTCASE TEST_CASE_ID={test_name} RESULT={test_result}>')