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

Tests fail on Python 3.7 - call.args[0] == "args" #4

Closed
JDeeth opened this issue Nov 2, 2023 · 0 comments
Closed

Tests fail on Python 3.7 - call.args[0] == "args" #4

JDeeth opened this issue Nov 2, 2023 · 0 comments
Labels
quality Tech debt / refactoring to make the code easier to work on

Comments

@JDeeth
Copy link
Owner

JDeeth commented Nov 2, 2023

In Python 3.7, a mock call is a tuple. From 3.8 onwards it's a named tuple. In 3.7, assert [c.args[0] for c in mocked_item.mock_calls] = ["a", "b", "c"] does something non-obvious like create a method named args, and [0] returns its name.

Solution is to access the call's args by its position in the tuple - some_call[1] not some_call.args

@JDeeth JDeeth added the quality Tech debt / refactoring to make the code easier to work on label Nov 2, 2023
@JDeeth JDeeth closed this as completed in 1031de1 Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality Tech debt / refactoring to make the code easier to work on
Projects
None yet
Development

No branches or pull requests

1 participant