Skip to content

Conversation

@bdrung
Copy link
Contributor

@bdrung bdrung commented Feb 21, 2024

Calling MagicMock.called_once, MagicMock.called_once_with, or MagicMock.not_called returns a mock object and asserting that always succeeds.

Replace those calls with their correct MagicMock.assert_* counterparts.

Discussion: Benefits and Drawbacks

Python 3.12 started to complain about it.

Proposed Release Note Entry

test: fix assertions for mock calls (for Python 3.12)

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

…alse

Calling `MagicMock.called_once_with` returns a mock object and asserting
that always succeeds. Replace this call with
`MagicMock.assert_called_with` in
`test_create_netbox_object_check_mode_false` since
`endpoint_mock.create` is called twice: once in the test setup and once
by `_create_netbox_object`.

Signed-off-by: Benjamin Drung <[email protected]>
Calling `MagicMock.called_once`, `MagicMock.called_once_with`, or
`MagicMock.not_called` returns a mock object and asserting that always
succeeds.

Replace those calls with their correct `MagicMock.assert_*`
counterparts.

Signed-off-by: Benjamin Drung <[email protected]>
@sc68cal sc68cal merged commit 784e228 into netbox-community:devel Mar 16, 2024
@bdrung bdrung deleted the python3.12 branch March 16, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants