Skip to content

Commit

Permalink
fix(test): Expect the correct module name for Python's 3.14 argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
befeleme committed Jan 20, 2025
1 parent 92160eb commit 98001b7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/test_espefuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
print(f"\nHost tests of espefuse.py for {arg_chip}:")
print("Running espefuse.py tests...")

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


@pytest.mark.host_test
class EfuseTestCase:
Expand Down Expand Up @@ -173,11 +179,13 @@ def _run_command(self, cmd, check_msg, ret_code):

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

def test_help2(self):
self.espefuse_not_virt_py("", check_msg="usage: __main__.py [-h]", ret_code=1)
self.espefuse_not_virt_py(
"", check_msg=f"usage: {ESPEFUSE_MODNAME} [-h]", ret_code=1
)

def test_dump(self):
self.espefuse_py("dump -h")
Expand Down Expand Up @@ -1973,17 +1981,17 @@ def test_multiple_cmds_help(self):

self.espefuse_py(
f"-h {command1} {command2}",
check_msg="usage: __main__.py [-h]",
check_msg=f"usage: {ESPEFUSE_MODNAME} [-h]",
)

self.espefuse_py(
f"{command1} -h {command2}",
check_msg="usage: __main__.py burn_key_digest [-h]",
check_msg=f"usage: {ESPEFUSE_MODNAME} burn_key_digest [-h]",
)

self.espefuse_py(
f"{command1} {command2} -h",
check_msg="usage: __main__.py burn_key [-h]",
check_msg=f"usage: {ESPEFUSE_MODNAME} burn_key [-h]",
)

@pytest.mark.skipif(
Expand Down

0 comments on commit 98001b7

Please sign in to comment.