Option C oc_diagnostics
Loading...
Searching...
No Matches
test_shim.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
# tests/test_shim.py
4
5
"""
6
pytest Compatibility Shim — oc_diagnostics
7
==========================================
8
9
Purpose
10
-------
11
Allow CI systems and contributors that use ``pytest`` as their standard
12
test-runner entry point to invoke the full ``oc_diagnostics`` test suite
13
without knowledge of the custom ``tests/run_tests.py`` runner (OI-20 / FS-11).
14
15
How it works
16
------------
17
A single pytest test function runs ``tests/run_tests.py`` as a subprocess and
18
asserts exit code 0. The custom Option C runner is unchanged; this file is a
19
thin adapter only.
20
21
Usage
22
-----
23
pytest tests/test_shim.py # run via pytest
24
python tests/run_tests.py # run directly (preferred for development)
25
"""
26
27
import
os
28
import
subprocess
29
import
sys
30
31
import
pytest
32
33
_REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__),
".."
))
34
_RUN_TESTS = os.path.join(_REPO_ROOT,
"tests"
,
"run_tests.py"
)
35
36
37
def
test_oc_diagnostics_suite
():
38
"""Run the full oc_diagnostics suite via the custom tests/run_tests.py runner.
39
40
Passes when run_tests.py exits 0 (all non-skipped tests pass).
41
Fails with the captured output when run_tests.py exits non-zero.
42
"""
43
result = subprocess.run(
44
[sys.executable, _RUN_TESTS],
45
cwd=_REPO_ROOT,
46
capture_output=
True
,
47
text=
True
,
48
timeout=120,
49
)
50
51
if
result.returncode != 0:
52
output = (result.stdout + result.stderr).strip()
53
pytest.fail(
54
f
"run_tests.py exited with code {result.returncode}:\n{output}"
55
)
test_shim.test_oc_diagnostics_suite
test_oc_diagnostics_suite()
Definition
test_shim.py:37
tests
test_shim.py
Generated by
1.15.0