pytest-embedded 2.9.3__tar.gz → 2.10.1__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.9.3 → pytest_embedded-2.10.1}/PKG-INFO +29 -2
- pytest_embedded-2.10.1/README.md +30 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/__init__.py +1 -1
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/dut_factory.py +40 -5
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/plugin.py +37 -14
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/tests/test_base.py +49 -1
- pytest_embedded-2.9.3/README.md +0 -3
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/LICENSE +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pyproject.toml +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/app.py +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/dut.py +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/log.py +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/unity.py +0 -0
- {pytest_embedded-2.9.3 → pytest_embedded-2.10.1}/pytest_embedded/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-embedded
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.1
|
|
4
4
|
Summary: A pytest plugin that designed for embedded testing.
|
|
5
5
|
Author-email: Fu Hanxi <fuhanxi@espressif.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -30,5 +30,32 @@ Project-URL: repository, https://github.com/espressif/pytest-embedded
|
|
|
30
30
|
|
|
31
31
|
### pytest-embedded
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The core plugin for the `pytest-embedded` framework. Designed for embedded testing across multiple targets and environments.
|
|
34
|
+
|
|
35
|
+
#### Key Features
|
|
36
|
+
|
|
37
|
+
- **Core Fixtures**: Provides essential fixtures including `dut`, `app`, `msg_queue`, `pexpect_proc`, and `redirect`.
|
|
38
|
+
- **String & Regex Matching**: Integrates `pexpect` for powerful output parsing with `dut.expect()` and `dut.expect_exact()`.
|
|
39
|
+
- **Multi-DUT Orchestration**: Test multi-device topologies (such as master-slave or mesh networks) using `--count`.
|
|
40
|
+
- **Flexible Parametrization**: Easily parametrize apps, targets, and services using `pytest` markers.
|
|
41
|
+
- **Unified Test Reports**: Parse and merge embedded Unity test results into JUnit XML reports.
|
|
42
|
+
|
|
43
|
+
#### Quickstart
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from pytest_embedded import Dut
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_basic_expect(redirect, dut: Dut):
|
|
50
|
+
with redirect():
|
|
51
|
+
print('Ready to test!')
|
|
52
|
+
|
|
53
|
+
dut.expect('Ready to test!')
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Run the test:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
pytest test_basic.py -s
|
|
60
|
+
```
|
|
34
61
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
### pytest-embedded
|
|
2
|
+
|
|
3
|
+
The core plugin for the `pytest-embedded` framework. Designed for embedded testing across multiple targets and environments.
|
|
4
|
+
|
|
5
|
+
#### Key Features
|
|
6
|
+
|
|
7
|
+
- **Core Fixtures**: Provides essential fixtures including `dut`, `app`, `msg_queue`, `pexpect_proc`, and `redirect`.
|
|
8
|
+
- **String & Regex Matching**: Integrates `pexpect` for powerful output parsing with `dut.expect()` and `dut.expect_exact()`.
|
|
9
|
+
- **Multi-DUT Orchestration**: Test multi-device topologies (such as master-slave or mesh networks) using `--count`.
|
|
10
|
+
- **Flexible Parametrization**: Easily parametrize apps, targets, and services using `pytest` markers.
|
|
11
|
+
- **Unified Test Reports**: Parse and merge embedded Unity test results into JUnit XML reports.
|
|
12
|
+
|
|
13
|
+
#### Quickstart
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from pytest_embedded import Dut
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_basic_expect(redirect, dut: Dut):
|
|
20
|
+
with redirect():
|
|
21
|
+
print('Ready to test!')
|
|
22
|
+
|
|
23
|
+
dut.expect('Ready to test!')
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run the test:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
pytest test_basic.py -s
|
|
30
|
+
```
|
|
@@ -13,7 +13,7 @@ from collections import defaultdict
|
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
|
|
15
15
|
if t.TYPE_CHECKING:
|
|
16
|
-
from pytest_embedded_espemu import EspEmu
|
|
16
|
+
from pytest_embedded_espemu import EspEmu, EspEmuSerial
|
|
17
17
|
from pytest_embedded_idf import LinuxSerial
|
|
18
18
|
from pytest_embedded_idf.dut import IdfDut
|
|
19
19
|
from pytest_embedded_jtag import Gdb, OpenOcd
|
|
@@ -162,6 +162,7 @@ def _fixture_classes_and_options_fn(
|
|
|
162
162
|
espemu_prog_path,
|
|
163
163
|
espemu_cli_args,
|
|
164
164
|
espemu_extra_args,
|
|
165
|
+
espemu_efuse_path,
|
|
165
166
|
wokwi_diagram,
|
|
166
167
|
wokwi_usb_serial_jtag,
|
|
167
168
|
skip_regenerate_image,
|
|
@@ -180,6 +181,15 @@ def _fixture_classes_and_options_fn(
|
|
|
180
181
|
mixins: dict[str, list[type]] = defaultdict(list)
|
|
181
182
|
kwargs: dict[str, dict[str, t.Any]] = defaultdict(dict)
|
|
182
183
|
|
|
184
|
+
# The emulator and its serial are two fixtures talking over one control
|
|
185
|
+
# channel, so the port is settled here, before either exists, and each is
|
|
186
|
+
# handed it.
|
|
187
|
+
espemu_control_port = None
|
|
188
|
+
if 'espemu' in _services:
|
|
189
|
+
from pytest_embedded_espemu import EspEmu
|
|
190
|
+
|
|
191
|
+
espemu_control_port = EspEmu.pick_control_port(espemu_prog_path)
|
|
192
|
+
|
|
183
193
|
for fixture in FIXTURES_SERVICES.keys():
|
|
184
194
|
if fixture == 'app':
|
|
185
195
|
kwargs['app'] = {'app_path': app_path, 'build_dir': build_dir}
|
|
@@ -210,6 +220,8 @@ def _fixture_classes_and_options_fn(
|
|
|
210
220
|
'part_tool': part_tool,
|
|
211
221
|
'espemu_image_path': espemu_image_path,
|
|
212
222
|
'skip_regenerate_image': skip_regenerate_image,
|
|
223
|
+
'encrypt': encrypt,
|
|
224
|
+
'keyfile': keyfile,
|
|
213
225
|
}
|
|
214
226
|
)
|
|
215
227
|
else:
|
|
@@ -289,6 +301,14 @@ def _fixture_classes_and_options_fn(
|
|
|
289
301
|
from pytest_embedded_serial_esp import EspSerial
|
|
290
302
|
|
|
291
303
|
classes[fixture] = EspSerial
|
|
304
|
+
elif 'espemu' in _services:
|
|
305
|
+
from pytest_embedded_espemu import EspEmuSerial
|
|
306
|
+
|
|
307
|
+
classes[fixture] = EspEmuSerial
|
|
308
|
+
kwargs[fixture] = {
|
|
309
|
+
'control_port': espemu_control_port,
|
|
310
|
+
'app': None,
|
|
311
|
+
}
|
|
292
312
|
elif 'serial' in _services or 'jtag' in _services:
|
|
293
313
|
from pytest_embedded_serial.serial import Serial
|
|
294
314
|
|
|
@@ -336,8 +356,14 @@ def _fixture_classes_and_options_fn(
|
|
|
336
356
|
kwargs[fixture] = {
|
|
337
357
|
'msg_queue': msg_queue,
|
|
338
358
|
'qemu_image_path': qemu_image_path
|
|
339
|
-
or
|
|
340
|
-
|
|
359
|
+
or (
|
|
360
|
+
None
|
|
361
|
+
if 'arduino' in _services
|
|
362
|
+
else os.path.join(
|
|
363
|
+
app_path or '',
|
|
364
|
+
build_dir or 'build',
|
|
365
|
+
ENCRYPTED_IMAGE_FN if encrypt else DEFAULT_IMAGE_FN,
|
|
366
|
+
)
|
|
341
367
|
),
|
|
342
368
|
'qemu_prog_path': qemu_prog_path,
|
|
343
369
|
'qemu_cli_args': qemu_cli_args,
|
|
@@ -351,6 +377,7 @@ def _fixture_classes_and_options_fn(
|
|
|
351
377
|
if 'espemu' in _services:
|
|
352
378
|
from pytest_embedded_espemu import (
|
|
353
379
|
DEFAULT_IMAGE_FN,
|
|
380
|
+
ENCRYPTED_IMAGE_FN,
|
|
354
381
|
EspEmu,
|
|
355
382
|
)
|
|
356
383
|
|
|
@@ -358,10 +385,14 @@ def _fixture_classes_and_options_fn(
|
|
|
358
385
|
kwargs[fixture] = {
|
|
359
386
|
'msg_queue': msg_queue,
|
|
360
387
|
'espemu_image_path': espemu_image_path
|
|
361
|
-
or os.path.join(
|
|
388
|
+
or os.path.join(
|
|
389
|
+
app_path or '', build_dir or 'build', ENCRYPTED_IMAGE_FN if encrypt else DEFAULT_IMAGE_FN
|
|
390
|
+
),
|
|
362
391
|
'espemu_prog_path': espemu_prog_path,
|
|
363
392
|
'espemu_cli_args': espemu_cli_args,
|
|
364
393
|
'espemu_extra_args': espemu_extra_args,
|
|
394
|
+
'espemu_efuse_path': espemu_efuse_path,
|
|
395
|
+
'espemu_control_port': espemu_control_port,
|
|
365
396
|
'app': None,
|
|
366
397
|
'meta': _meta,
|
|
367
398
|
}
|
|
@@ -423,6 +454,7 @@ def _fixture_classes_and_options_fn(
|
|
|
423
454
|
kwargs[fixture].update(
|
|
424
455
|
{
|
|
425
456
|
'espemu': None,
|
|
457
|
+
'serial': None,
|
|
426
458
|
}
|
|
427
459
|
)
|
|
428
460
|
elif 'qemu' in _services:
|
|
@@ -510,7 +542,7 @@ def app_fn(_fixture_classes_and_options: ClassCliOptions) -> App:
|
|
|
510
542
|
return cls(**_drop_none_kwargs(kwargs))
|
|
511
543
|
|
|
512
544
|
|
|
513
|
-
def serial_gn(_fixture_classes_and_options, msg_queue, app) -> t.Union['Serial', 'LinuxSerial'] | None:
|
|
545
|
+
def serial_gn(_fixture_classes_and_options, msg_queue, app) -> t.Union['Serial', 'LinuxSerial'] | 'EspEmuSerial' | None:
|
|
514
546
|
if hasattr(app, 'target') and app.target == 'linux':
|
|
515
547
|
from pytest_embedded_idf import LinuxSerial
|
|
516
548
|
|
|
@@ -764,6 +796,7 @@ class DutFactory:
|
|
|
764
796
|
espemu_prog_path: str | None = None,
|
|
765
797
|
espemu_cli_args: str | None = None,
|
|
766
798
|
espemu_extra_args: str | None = None,
|
|
799
|
+
espemu_efuse_path: str | None = None,
|
|
767
800
|
wokwi_diagram: str | None = None,
|
|
768
801
|
wokwi_usb_serial_jtag: bool | None = None,
|
|
769
802
|
skip_regenerate_image: bool | None = None,
|
|
@@ -816,6 +849,7 @@ class DutFactory:
|
|
|
816
849
|
espemu_prog_path: esp-emu program path.
|
|
817
850
|
espemu_cli_args: esp-emu CLI arguments.
|
|
818
851
|
espemu_extra_args: Additional esp-emu arguments.
|
|
852
|
+
espemu_efuse_path: esp-emu eFuse image path.
|
|
819
853
|
wokwi_diagram: Wokwi diagram path.
|
|
820
854
|
wokwi_usb_serial_jtag: Use USB Serial JTAG instead of UART for Wokwi serial communication.
|
|
821
855
|
skip_regenerate_image: Skip image regeneration flag.
|
|
@@ -892,6 +926,7 @@ class DutFactory:
|
|
|
892
926
|
'espemu_prog_path': espemu_prog_path,
|
|
893
927
|
'espemu_cli_args': espemu_cli_args,
|
|
894
928
|
'espemu_extra_args': espemu_extra_args,
|
|
929
|
+
'espemu_efuse_path': espemu_efuse_path,
|
|
895
930
|
'wokwi_diagram': wokwi_diagram,
|
|
896
931
|
'wokwi_usb_serial_jtag': wokwi_usb_serial_jtag,
|
|
897
932
|
'skip_regenerate_image': skip_regenerate_image,
|
|
@@ -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',
|
|
@@ -233,7 +240,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
233
240
|
idf_group.addoption(
|
|
234
241
|
'--part-tool',
|
|
235
242
|
help='Partition tool path, used for parsing partition table. '
|
|
236
|
-
'(Default: "$IDF_PATH/components/partition_table/gen_esp32part.py"',
|
|
243
|
+
'(Default: "$IDF_PATH/components/partition_table/gen_esp32part.py")',
|
|
237
244
|
)
|
|
238
245
|
idf_group.addoption(
|
|
239
246
|
'--confirm-target-elf-sha256',
|
|
@@ -259,7 +266,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
259
266
|
jtag_group.addoption('--gdb-prog-path', help='GDB program path. (Default: "xtensa-esp32-elf-gdb")')
|
|
260
267
|
jtag_group.addoption(
|
|
261
268
|
'--gdb-cli-args',
|
|
262
|
-
help='GDB cli arguments. (Default: "--quiet"',
|
|
269
|
+
help='GDB cli arguments. (Default: "--quiet")',
|
|
263
270
|
)
|
|
264
271
|
jtag_group.addoption(
|
|
265
272
|
'--no-gdb',
|
|
@@ -291,7 +298,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
291
298
|
)
|
|
292
299
|
qemu_group.addoption(
|
|
293
300
|
'--qemu-efuse-path',
|
|
294
|
-
help='
|
|
301
|
+
help='Path to an eFuse file for QEMU simulation. (Default: None)',
|
|
295
302
|
)
|
|
296
303
|
qemu_group.addoption(
|
|
297
304
|
'--skip-regenerate-image',
|
|
@@ -300,7 +307,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
300
307
|
)
|
|
301
308
|
qemu_group.addoption(
|
|
302
309
|
'--encrypt',
|
|
303
|
-
help='y/yes/true for True and n/no/false for False. Set to True for pre-encryption workflow (Default: False)',
|
|
310
|
+
help='y/yes/true for True and n/no/false for False. Set to True for pre-encryption workflow. (Default: False)',
|
|
304
311
|
)
|
|
305
312
|
qemu_group.addoption(
|
|
306
313
|
'--keyfile',
|
|
@@ -320,6 +327,11 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
320
327
|
'--espemu-cli-args',
|
|
321
328
|
help='esp-emu cli default arguments. (Default: None)',
|
|
322
329
|
)
|
|
330
|
+
espemu_group.addoption(
|
|
331
|
+
'--espemu-efuse-path',
|
|
332
|
+
help='esp-emu eFuse image path. The emulator reads it at start and writes it back on exit. '
|
|
333
|
+
'A blank image is created when the file does not exist. (Default: None)',
|
|
334
|
+
)
|
|
323
335
|
espemu_group.addoption(
|
|
324
336
|
'--espemu-extra-args',
|
|
325
337
|
help='esp-emu cli extra arguments, will append to the argument list. (Default: None)',
|
|
@@ -328,7 +340,7 @@ def pytest_addoption(parser: pytest.Parser):
|
|
|
328
340
|
wokwi_group = parser.getgroup('embedded-wokwi')
|
|
329
341
|
wokwi_group.addoption(
|
|
330
342
|
'--wokwi-diagram',
|
|
331
|
-
help='Path to the wokwi diagram file (Default: None)',
|
|
343
|
+
help='Path to the wokwi diagram file. (Default: None)',
|
|
332
344
|
)
|
|
333
345
|
wokwi_group.addoption(
|
|
334
346
|
'--wokwi-usb-serial-jtag',
|
|
@@ -422,10 +434,8 @@ def parse_multi_dut_args(count: int, s: str) -> t.Any | tuple[t.Any]:
|
|
|
422
434
|
return tuple(_str_bool(item) for item in res)
|
|
423
435
|
|
|
424
436
|
|
|
425
|
-
def multi_dut_argument(func) -> t.Callable[..., str |
|
|
426
|
-
"""
|
|
427
|
-
Used for parse the multi-dut argument according to the `count` amount.
|
|
428
|
-
"""
|
|
437
|
+
def multi_dut_argument(func) -> t.Callable[..., str | tuple[str | None, ...] | None]:
|
|
438
|
+
"""Decorator to parse the multi-dut argument based on the `count` parameter."""
|
|
429
439
|
|
|
430
440
|
@functools.wraps(func)
|
|
431
441
|
def wrapper(*args, **kwargs):
|
|
@@ -870,7 +880,13 @@ def embedded_services(request: FixtureRequest) -> str | None:
|
|
|
870
880
|
def app_path(request: FixtureRequest, test_file_path: str, record_xml_attribute) -> str | None:
|
|
871
881
|
"""Enable parametrization for the same cli option"""
|
|
872
882
|
res = _request_param_or_config_option_or_default(request, 'app_path', os.path.dirname(test_file_path))
|
|
873
|
-
|
|
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)
|
|
874
890
|
return res
|
|
875
891
|
|
|
876
892
|
|
|
@@ -1115,6 +1131,13 @@ def espemu_cli_args(request: FixtureRequest) -> str | None:
|
|
|
1115
1131
|
return _request_param_or_config_option_or_default(request, 'espemu_cli_args', None)
|
|
1116
1132
|
|
|
1117
1133
|
|
|
1134
|
+
@pytest.fixture
|
|
1135
|
+
@multi_dut_argument
|
|
1136
|
+
def espemu_efuse_path(request: FixtureRequest) -> str | None:
|
|
1137
|
+
"""Enable parametrization for the same cli option"""
|
|
1138
|
+
return _request_param_or_config_option_or_default(request, 'espemu_efuse_path', None)
|
|
1139
|
+
|
|
1140
|
+
|
|
1118
1141
|
@pytest.fixture
|
|
1119
1142
|
@multi_dut_argument
|
|
1120
1143
|
def espemu_extra_args(request: FixtureRequest) -> str | None:
|
|
@@ -1222,6 +1245,7 @@ def parametrize_fixtures(
|
|
|
1222
1245
|
espemu_prog_path,
|
|
1223
1246
|
espemu_cli_args,
|
|
1224
1247
|
espemu_extra_args,
|
|
1248
|
+
espemu_efuse_path,
|
|
1225
1249
|
wokwi_diagram,
|
|
1226
1250
|
wokwi_usb_serial_jtag,
|
|
1227
1251
|
skip_regenerate_image,
|
|
@@ -1477,14 +1501,13 @@ class PytestEmbedded:
|
|
|
1477
1501
|
skip_marker = item.get_closest_marker('skip_if_soc')
|
|
1478
1502
|
if not skip_marker:
|
|
1479
1503
|
continue
|
|
1480
|
-
|
|
1504
|
+
services = self.get_param(item, 'embedded_services', config.getoption('embedded_services', ''))
|
|
1505
|
+
if 'idf' not in map(str.strip, (services or '').split(',')):
|
|
1481
1506
|
raise ValueError("'skip_if_soc' marker must be used with the 'idf' embedded service.")
|
|
1482
1507
|
|
|
1483
1508
|
from esp_bool_parser import parse_bool_expr
|
|
1484
1509
|
|
|
1485
|
-
target = config.getoption('target', None)
|
|
1486
|
-
if hasattr(item, 'callspec'):
|
|
1487
|
-
target = item.callspec.params.get('target', None)
|
|
1510
|
+
target = self.get_param(item, 'target', config.getoption('target', None))
|
|
1488
1511
|
if target == 'auto' or not isinstance(target, str):
|
|
1489
1512
|
warnings.warn(
|
|
1490
1513
|
f"Ignoring pytest.mark.skip_if_soc for test item '{item.originalname}': "
|
|
@@ -35,7 +35,7 @@ def test_services(testdir):
|
|
|
35
35
|
('idf,serial', {'IdfApp', 'Serial', 'SerialDut'}),
|
|
36
36
|
('idf,esp', {'IdfApp', 'IdfSerial', 'IdfDut'}),
|
|
37
37
|
('idf,qemu', {'QemuApp', 'Qemu', 'QemuDut'}),
|
|
38
|
-
('idf,espemu', {'EspEmuApp', 'EspEmu', 'EspEmuDut'}),
|
|
38
|
+
('idf,espemu', {'EspEmuApp', 'EspEmu', 'EspEmuSerial', 'EspEmuDut'}),
|
|
39
39
|
('arduino,esp', {'ArduinoApp', 'ArduinoSerial', 'SerialDut'}),
|
|
40
40
|
],
|
|
41
41
|
indirect=True
|
|
@@ -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
|
[
|
pytest_embedded-2.9.3/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|