Skip to content

Commit

Permalink
fix test has_calls
Browse files Browse the repository at this point in the history
Tests on python 3.12 are failing with:

```
$ pytest -k 'test_generate_jwt_with_passphrase'
FAILED tests/test_connection.py::test_generate_jwt_with_passphrase[pass123] - AttributeError: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute.
FAILED tests/test_connection.py::test_generate_jwt_with_passphrase[] - AttributeError: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute.
```

This commit fixes has_calls usage by replacing it with assert_has_calls
  • Loading branch information
sfc-gh-vtimofeenko committed Nov 25, 2024
1 parent a97d5ad commit 4165843
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,16 +1219,19 @@ def test_generate_jwt_with_passphrase(
result.output
== "Enter private key file password (press enter for empty) []: \nfunny token\n"
)
mocked_get_token.has_calls(
mock.call(
user="FooBar", account="account1", privatekey_path=str(f), key_password=None
),
mock.call(
user="FooBar",
account="account1",
privatekey_path=str(f),
key_password=passphrase,
),
mocked_get_token.assert_has_calls(
[
mock.call(
user="FooBar", account="account1", privatekey_path=str(f), key_password=None
),
mock.call(
user="FooBar",
account="account1",
privatekey_path=str(f),
key_password=passphrase,
),
],
any_order=True
)


Expand Down

0 comments on commit 4165843

Please sign in to comment.