pytest-embedded 2.10.0__tar.gz → 2.10.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/PKG-INFO +1 -1
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/__init__.py +1 -1
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/plugin.py +14 -1
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/tests/test_base.py +48 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/LICENSE +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/README.md +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pyproject.toml +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/app.py +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/dut.py +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/dut_factory.py +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/log.py +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/unity.py +0 -0
- {pytest_embedded-2.10.0 → pytest_embedded-2.10.2}/pytest_embedded/utils.py +0 -0
|
@@ -16,6 +16,7 @@ import warnings
|
|
|
16
16
|
import xml.dom.minidom
|
|
17
17
|
from collections import Counter
|
|
18
18
|
from operator import itemgetter
|
|
19
|
+
from pathlib import Path
|
|
19
20
|
|
|
20
21
|
import filelock
|
|
21
22
|
import pytest
|
|
@@ -73,6 +74,12 @@ _T = t.TypeVar('_T')
|
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
def pytest_addoption(parser: pytest.Parser):
|
|
77
|
+
parser.addini(
|
|
78
|
+
'junit_app_path_relative_to_root',
|
|
79
|
+
'Record JUnit app_path relative to the pytest root directory when the app is inside it.',
|
|
80
|
+
type='bool',
|
|
81
|
+
default=False,
|
|
82
|
+
)
|
|
76
83
|
base_group = parser.getgroup('embedded')
|
|
77
84
|
base_group.addoption(
|
|
78
85
|
'--count',
|
|
@@ -873,7 +880,13 @@ def embedded_services(request: FixtureRequest) -> str | None:
|
|
|
873
880
|
def app_path(request: FixtureRequest, test_file_path: str, record_xml_attribute) -> str | None:
|
|
874
881
|
"""Enable parametrization for the same cli option"""
|
|
875
882
|
res = _request_param_or_config_option_or_default(request, 'app_path', os.path.dirname(test_file_path))
|
|
876
|
-
|
|
883
|
+
report_path = res
|
|
884
|
+
if res and request.config.getini('junit_app_path_relative_to_root') and Path(res).is_absolute():
|
|
885
|
+
try:
|
|
886
|
+
report_path = str(Path(res).resolve().relative_to(request.config.rootpath.resolve()))
|
|
887
|
+
except ValueError:
|
|
888
|
+
pass
|
|
889
|
+
record_xml_attribute('app_path', report_path)
|
|
877
890
|
return res
|
|
878
891
|
|
|
879
892
|
|
|
@@ -153,6 +153,54 @@ def test_default_app_path(testdir):
|
|
|
153
153
|
result.assert_outcomes(passed=1)
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
@pytest.mark.parametrize('enabled', [False, True])
|
|
157
|
+
def test_junit_app_path_relative_to_root(testdir, enabled):
|
|
158
|
+
root = Path(str(testdir.tmpdir))
|
|
159
|
+
app_paths = [str(root / 'components' / 'app'), str(root.parent / (root.name + '-other') / 'app'), 'relative/app']
|
|
160
|
+
if enabled:
|
|
161
|
+
testdir.makepyprojecttoml("""
|
|
162
|
+
[tool.pytest.ini_options]
|
|
163
|
+
junit_app_path_relative_to_root = true
|
|
164
|
+
junit_family = "xunit1"
|
|
165
|
+
""")
|
|
166
|
+
testdir.makepyfile(f"""
|
|
167
|
+
import pytest
|
|
168
|
+
|
|
169
|
+
@pytest.mark.parametrize('app_path', {app_paths!r}, indirect=True)
|
|
170
|
+
def test_app(app_path, request):
|
|
171
|
+
assert app_path == request.node.callspec.params['app_path']
|
|
172
|
+
""")
|
|
173
|
+
|
|
174
|
+
result = testdir.runpytest('--junitxml=result.xml')
|
|
175
|
+
result.assert_outcomes(passed=3)
|
|
176
|
+
assert [case.get('app_path') for case in ET.parse(root / 'result.xml').iter('testcase')] == [
|
|
177
|
+
'components/app' if enabled else app_paths[0],
|
|
178
|
+
app_paths[1],
|
|
179
|
+
app_paths[2],
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def test_junit_app_path_uses_overridden_rootdir(testdir):
|
|
184
|
+
root = Path(str(testdir.tmpdir))
|
|
185
|
+
(root / 'project').mkdir()
|
|
186
|
+
testdir.makepyprojecttoml("""
|
|
187
|
+
[tool.pytest.ini_options]
|
|
188
|
+
junit_app_path_relative_to_root = true
|
|
189
|
+
junit_family = "xunit1"
|
|
190
|
+
""")
|
|
191
|
+
testdir.makepyfile(f"""
|
|
192
|
+
import pytest
|
|
193
|
+
|
|
194
|
+
@pytest.mark.parametrize('app_path', [{str(root / 'project/components/app')!r}], indirect=True)
|
|
195
|
+
def test_app(app_path):
|
|
196
|
+
pass
|
|
197
|
+
""")
|
|
198
|
+
|
|
199
|
+
result = testdir.runpytest('--rootdir=project', '--junitxml=result.xml')
|
|
200
|
+
result.assert_outcomes(passed=1)
|
|
201
|
+
assert [case.get('app_path') for case in ET.parse(root / 'result.xml').iter('testcase')] == ['components/app']
|
|
202
|
+
|
|
203
|
+
|
|
156
204
|
@pytest.mark.parametrize(
|
|
157
205
|
'parallel_count, parallel_index, res',
|
|
158
206
|
[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|