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

test: fix assertions for mock calls #1178

Merged
merged 2 commits into from
Mar 16, 2024
Merged

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 <benjamin.drung@canonical.com>
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 <benjamin.drung@canonical.com>
@sc68cal sc68cal merged commit 784e228 into netbox-community:devel Mar 16, 2024
8 checks passed
@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.

None yet

2 participants