Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.14: new argparse output shows module name instead of __main__.py - causing 3 tests to fail (ESPTOOL-996) #1054

Closed
befeleme opened this issue Jan 20, 2025 · 1 comment · Fixed by #1055

Comments

@befeleme
Copy link
Contributor

Operating System

Fedora Linux 43

Esptool Version

4.8.1

Python Version

3.14.0a4

Full Esptool Command Line that Was Run

No response

Esptool Output

_________________ TestMultipleCommands.test_multiple_cmds_help _________________

self = <test_espefuse.TestMultipleCommands object at 0x7fe99e083b10>

    def test_multiple_cmds_help(self):
        if arg_chip == "esp32c2":
            command1 = (
                f"burn_key_digest {S_IMAGES_DIR}"
                "/ecdsa256_secure_boot_signing_key_v2.pem"
            )
            command2 = (
                f"burn_key BLOCK_KEY0 {IMAGES_DIR}/128bit_key "
                "XTS_AES_128_KEY_DERIVED_FROM_128_EFUSE_BITS"
            )
        elif arg_chip == "esp32":
            command1 = f"burn_key_digest {S_IMAGES_DIR}/rsa_secure_boot_signing_key.pem"
            command2 = f"burn_key flash_encryption {IMAGES_DIR}/256bit"
        else:
            command1 = f"burn_key_digest BLOCK_KEY0 \
            {S_IMAGES_DIR}/rsa_secure_boot_signing_key.pem SECURE_BOOT_DIGEST0"
            command2 = f"burn_key BLOCK_KEY0 \
            {S_IMAGES_DIR}/rsa_public_key_digest.bin SECURE_BOOT_DIGEST0"
    
>       self.espefuse_py(
            f"-h {command1} {command2}",
            check_msg="usage: __main__.py [-h]",
        )

test/test_espefuse.py:1955: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test/test_espefuse.py:144: in espefuse_py
    output = self._run_command(full_cmd, check_msg, ret_code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_espefuse.TestMultipleCommands object at 0x7fe99e083b10>
cmd = '/usr/bin/python3 -m espefuse --chip esp32 --virt --path-efuse-file /tmp/tmpu2qa4q8w -d --do-not-confirm -h burn_key_d...ing_key.pem burn_key flash_encryption /builddir/build/BUILD/esptool-4.8.1-build/esptool-4.8.1/test/images/efuse/256bit'
check_msg = 'usage: __main__.py [-h]', ret_code = 0

    def _run_command(self, cmd, check_msg, ret_code):
        try:
            p = subprocess.Popen(
                cmd.split(),
                shell=False,
                stdin=subprocess.PIPE,
                stdout=subprocess.PIPE,
                universal_newlines=True,
            )
            output, _ = p.communicate()
            returncode = p.returncode
            if check_msg:
>               assert check_msg in output
E               AssertionError: assert 'usage: __main__.py [-h]' in 'espefuse.py v4.8.1\nusage: python3 -m espefuse [-h]\n                           [--chip {auto,esp32,esp32c2,esp32c3,e... --extend-efuse-table EXTEND_EFUSE_TABLE\n                        CSV file from ESP-IDF (esp_efuse_custom_table.csv)\n'

What is the Expected Behaviour?

No response

More Information

In Python 3.14 the output of the help produced by argparse is changed, causing 3 esptool tests to fail.
In tests, there's expected: 'usage: __main__.py [-h]', and actual: usage: python3 -m espefuse [-h], see: https://docs.python.org/dev/whatsnew/3.14.html#argparse

Failed tests:
FAILED test/test_espefuse.py::TestReadCommands::test_help
FAILED test/test_espefuse.py::TestReadCommands::test_help2
FAILED test/test_espefuse.py::TestMultipleCommands::test_multiple_cmds_help

Other Steps to Reproduce

No response

@github-actions github-actions bot changed the title Python 3.14: new argparse output shows module name instead of __main__.py - causing 3 tests to fail Python 3.14: new argparse output shows module name instead of __main__.py - causing 3 tests to fail (ESPTOOL-996) Jan 20, 2025
@Honza0297
Copy link
Collaborator

@befeleme Thanks for finding this out and preparing the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants