Skip to content

Commit 98001b7

Browse files
committed
fix(test): Expect the correct module name for Python's 3.14 argparse
1 parent 92160eb commit 98001b7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/test_espefuse.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
print(f"\nHost tests of espefuse.py for {arg_chip}:")
6464
print("Running espefuse.py tests...")
6565

66+
# The default value of the program name for argparse has changed in Python 3.14
67+
# https://docs.python.org/dev/whatsnew/3.14.html#argparse
68+
ESPEFUSE_MODNAME = (
69+
"__main__.py" if sys.version_info < (3, 14) else "python3 -m espefuse"
70+
)
71+
6672

6773
@pytest.mark.host_test
6874
class EfuseTestCase:
@@ -173,11 +179,13 @@ def _run_command(self, cmd, check_msg, ret_code):
173179

174180
class TestReadCommands(EfuseTestCase):
175181
def test_help(self):
176-
self.espefuse_not_virt_py("--help", check_msg="usage: __main__.py [-h]")
182+
self.espefuse_not_virt_py("--help", check_msg=f"usage: {ESPEFUSE_MODNAME} [-h]")
177183
self.espefuse_not_virt_py(f"--chip {arg_chip} --help")
178184

179185
def test_help2(self):
180-
self.espefuse_not_virt_py("", check_msg="usage: __main__.py [-h]", ret_code=1)
186+
self.espefuse_not_virt_py(
187+
"", check_msg=f"usage: {ESPEFUSE_MODNAME} [-h]", ret_code=1
188+
)
181189

182190
def test_dump(self):
183191
self.espefuse_py("dump -h")
@@ -1973,17 +1981,17 @@ def test_multiple_cmds_help(self):
19731981

19741982
self.espefuse_py(
19751983
f"-h {command1} {command2}",
1976-
check_msg="usage: __main__.py [-h]",
1984+
check_msg=f"usage: {ESPEFUSE_MODNAME} [-h]",
19771985
)
19781986

19791987
self.espefuse_py(
19801988
f"{command1} -h {command2}",
1981-
check_msg="usage: __main__.py burn_key_digest [-h]",
1989+
check_msg=f"usage: {ESPEFUSE_MODNAME} burn_key_digest [-h]",
19821990
)
19831991

19841992
self.espefuse_py(
19851993
f"{command1} {command2} -h",
1986-
check_msg="usage: __main__.py burn_key [-h]",
1994+
check_msg=f"usage: {ESPEFUSE_MODNAME} burn_key [-h]",
19871995
)
19881996

19891997
@pytest.mark.skipif(

0 commit comments

Comments
 (0)