Skip to content

Commit

Permalink
Fix assertion in TestCheckParseValues::test_warns_bad_type
Browse files Browse the repository at this point in the history
Fix the assertion in TestCheckParseValues::test_warns_bad_type
to use `.assert_called_with()` rather than non-existing `.called_with()`
method.  The latter is wrongly interpreted as calling a mocked method
in Python < 3.12, and therefore does not test anything at all.  Starting
with Python 3.12, it results in an error:

    AttributeError: 'called_with' is not a valid assertion. Use a spec for the mock if 'called_with' is meant to be an attribute.

Fixing the call also revealed that the assertion was incorrect, so I've
updated it to match the current call.
  • Loading branch information
mgorny committed Nov 19, 2023
1 parent 2120b03 commit 8c09a6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/unit/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ def test_warns_bad_type(self, item):
with patch("tavern._core.dict_util.logger.warning") as wmock:
_check_and_format_values("{fd}", {"fd": item})

assert wmock.called_with(
"Formatting 'fd' will result in it being coerced to a string (it is a {})".format(
type(item)
)
wmock.assert_called_with(
"Formatting '%s' will result in it being coerced to a string (it is a %s)",
"fd",
type(item),
)

@pytest.mark.parametrize("item", [1, "a", 1.3, format_keys("{s}", {"s": 2})])
Expand Down

0 comments on commit 8c09a6f

Please sign in to comment.