Skip to content

Commit 63fc8cd

Browse files
authored
Merge pull request #340 from espressif/fix/app_path-for-python-case
fix: app_path haven't recorded in python cases
2 parents d54b9cd + b0b8a87 commit 63fc8cd

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
include:
2323
- python-version: "3.7"
24-
arch: "ARM"
24+
arch: "ARM64"
2525
- python-version: "3.13"
2626
arch: "X64"
2727
fail-fast: false

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import sys
4+
import textwrap
45
from typing import List, Pattern
56

67
import pytest
@@ -25,6 +26,14 @@ def copy_fixtures(testdir: Testdir):
2526
else:
2627
shutil.copytree(os.path.join(fixture_dir, item), os.path.join(str(testdir.tmpdir), item))
2728

29+
testdir.makepyprojecttoml(
30+
textwrap.dedent("""
31+
[tool.pytest.ini_options]
32+
filterwarnings = "ignore:FutureWarning"
33+
junit_family = "xunit1"
34+
""")
35+
)
36+
2837
yield
2938

3039

pytest-embedded/pytest_embedded/plugin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,11 @@ def embedded_services(request: FixtureRequest) -> t.Optional[str]:
749749

750750
@pytest.fixture
751751
@multi_dut_argument
752-
def app_path(request: FixtureRequest, test_file_path: str) -> t.Optional[str]:
752+
def app_path(request: FixtureRequest, test_file_path: str, record_xml_attribute) -> t.Optional[str]:
753753
"""Enable parametrization for the same cli option"""
754-
return _request_param_or_config_option_or_default(request, 'app_path', os.path.dirname(test_file_path))
754+
res = _request_param_or_config_option_or_default(request, 'app_path', os.path.dirname(test_file_path))
755+
record_xml_attribute('app_path', res)
756+
return res
755757

756758

757759
@pytest.fixture

pytest-embedded/tests/test_base.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,37 @@ def test_unclosed_file_handler(test_input, dut):
683683
result.assert_outcomes(passed=1024)
684684

685685

686+
def test_check_app_path_for_python_case(testdir):
687+
testdir.makepyfile(r"""
688+
import pytest
689+
690+
691+
def test_foo(dut):
692+
dut.write('foo')
693+
dut.expect_exact('foo')
694+
""")
695+
696+
result = testdir.runpytest(
697+
'--junitxml',
698+
'report.xml',
699+
'--app-path',
700+
'/tmp/foo',
701+
)
702+
result.assert_outcomes(passed=1)
703+
704+
junit_report = ET.parse('report.xml').getroot()[0]
705+
assert junit_report[0].get('app_path') == '/tmp/foo'
706+
707+
result = testdir.runpytest(
708+
'--junitxml',
709+
'report.xml',
710+
)
711+
result.assert_outcomes(passed=1)
712+
713+
junit_report = ET.parse('report.xml').getroot()[0]
714+
assert junit_report[0].get('app_path') == str(testdir)
715+
716+
686717
class TestTargetMarkers:
687718
def test_add_target_as_marker_simple(self, pytester):
688719
pytester.makepyfile("""

0 commit comments

Comments
 (0)