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

stm32loader: fix build with python 3.12 #333676

Merged

Conversation

ghpzin
Copy link
Contributor

@ghpzin ghpzin commented Aug 10, 2024

Description of changes

Fixes #332715 (Build failure: stm32loader)
Hydra build falure:
https://hydra.nixos.org/build/267612095

Build failure logs
============================= test session starts ==============================
platform linux -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
rootdir: /build/stm32loader-0.7.1
configfile: pyproject.toml
collected 49 items                                                             

tests/unit/test_arguments.py .....                                       [ 10%]
tests/unit/test_bootloader.py ..............................FFF......... [ 95%]
.                                                                        [ 97%]
tests/unit/test_hexfile.py .                                             [100%]

=================================== FAILURES ===================================
__________ test_get_uid_for_known_family_reads_at_correct_address[F1] __________

connection = <MagicMock id='140737318300720'>, family = 'F1'

    @pytest.mark.parametrize(
        "family", ["F1", "F3", "F7"],
    )
    def test_get_uid_for_known_family_reads_at_correct_address(connection, family):
        bootloader = Stm32Bootloader(connection, device_family=family)
        bootloader.read_memory = MagicMock()
        bootloader.get_uid()
        uid_address = bootloader.UID_ADDRESS[family]
>       assert bootloader.read_memory.called_once_with(uid_address)

tests/unit/test_bootloader.py:216: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock id='140737318289632'>, name = 'called_once_with'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods):
            if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST:
>               raise AttributeError(
                    f"{name!r} is not a valid assertion. Use a spec "
                    f"for the mock if {name!r} is meant to be an attribute.")
E               AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?

/nix/store/l014xp1qxdl6gim3zc0jv3mpxhbp346s-python3-3.12.4/lib/python3.12/unittest/mock.py:663: AttributeError
__________ test_get_uid_for_known_family_reads_at_correct_address[F3] __________

connection = <MagicMock id='140737324790560'>, family = 'F3'

    @pytest.mark.parametrize(
        "family", ["F1", "F3", "F7"],
    )
    def test_get_uid_for_known_family_reads_at_correct_address(connection, family):
        bootloader = Stm32Bootloader(connection, device_family=family)
        bootloader.read_memory = MagicMock()
        bootloader.get_uid()
        uid_address = bootloader.UID_ADDRESS[family]
>       assert bootloader.read_memory.called_once_with(uid_address)

tests/unit/test_bootloader.py:216: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock id='140737318384608'>, name = 'called_once_with'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods):
            if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST:
>               raise AttributeError(
                    f"{name!r} is not a valid assertion. Use a spec "
                    f"for the mock if {name!r} is meant to be an attribute.")
E               AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?

/nix/store/l014xp1qxdl6gim3zc0jv3mpxhbp346s-python3-3.12.4/lib/python3.12/unittest/mock.py:663: AttributeError
__________ test_get_uid_for_known_family_reads_at_correct_address[F7] __________

connection = <MagicMock id='140737318373664'>, family = 'F7'

    @pytest.mark.parametrize(
        "family", ["F1", "F3", "F7"],
    )
    def test_get_uid_for_known_family_reads_at_correct_address(connection, family):
        bootloader = Stm32Bootloader(connection, device_family=family)
        bootloader.read_memory = MagicMock()
        bootloader.get_uid()
        uid_address = bootloader.UID_ADDRESS[family]
>       assert bootloader.read_memory.called_once_with(uid_address)

tests/unit/test_bootloader.py:216: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock id='140737318299712'>, name = 'called_once_with'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods):
            if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST:
>               raise AttributeError(
                    f"{name!r} is not a valid assertion. Use a spec "
                    f"for the mock if {name!r} is meant to be an attribute.")
E               AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?

/nix/store/l014xp1qxdl6gim3zc0jv3mpxhbp346s-python3-3.12.4/lib/python3.12/unittest/mock.py:663: AttributeError
=========================== short test summary info ============================
FAILED tests/unit/test_bootloader.py::test_get_uid_for_known_family_reads_at_correct_address[F1] - AttributeError: 'called_once_with' is not a valid assertion. Use a spec for...
FAILED tests/unit/test_bootloader.py::test_get_uid_for_known_family_reads_at_correct_address[F3] - AttributeError: 'called_once_with' is not a valid assertion. Use a spec for...
FAILED tests/unit/test_bootloader.py::test_get_uid_for_known_family_reads_at_correct_address[F7] - AttributeError: 'called_once_with' is not a valid assertion. Use a spec for...
========================= 3 failed, 46 passed in 0.88s =========================
/nix/store/1r32fki5z5ivgaikgh8pq0r6vz3b0jpj-stdenv-linux/setup: line 1655: pop_var_context: head of shell_variables not a function context

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ghpzin
Copy link
Contributor Author

ghpzin commented Aug 10, 2024

Result of nixpkgs-review pr 333676 run on x86_64-linux 1

4 packages built:
  • python311Packages.stm32loader
  • python311Packages.stm32loader.dist
  • stm32loader (python312Packages.stm32loader)
  • stm32loader.dist (python312Packages.stm32loader.dist)

@ghpzin ghpzin marked this pull request as ready for review August 10, 2024 14:47
@pbsds pbsds merged commit 000ae0a into NixOS:master Aug 12, 2024
29 checks passed
@ghpzin ghpzin deleted the python312Packages.stm32loader/fix-python312-build branch August 12, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure: stm32loader
2 participants