Checklist
- [x ] I have included information about relevant versions
- [ x] I have verified that the issue persists when using the
master branch of Faust.
Steps to reproduce
Try and test with 3.12
Expected behavior
Green tests
Actual behavior
See tracebacks below
Probably related, though the fix doesn't help: miguelgrinberg/python-socketio#1265
Full traceback
def test_send_changelog_event(self, *, man, table, key, current_event): man.send_changelog_event(key, 3, "value")
> assert man.storage.__setitem__.called_once_with(key, "value")
tests/unit/tables/test_objects.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Mock name='mock.__setitem__' id='140414725685024'>, name = 'called_once_with'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name):
raise AttributeError(name)
if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods): if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST: > raise AttributeError(
f"{name!r} is not a valid assertion. Use a spec "
f"for the mock if {name!r} is meant to be an attribute.") E AttributeError: 'called_once_with' is not a valid assertion. Use a spec for the mock if 'called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?
After renaming the method with assert_ :
tests/unit/tables/test_objects.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _../../.asdf/installs/python/3.12.0/lib/python3.12/unittest/mock.py:956: in assert_called_once_with return self.assert_called_with(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Mock name='mock.__setitem__' id='140667361335760'>, args = (<Mock name='key' id='140667361334032'>, 'value'), kwargs = {} expected = call(<Mock name='key' id='140667361334032'>, 'value')
actual = call(<Mock name='key' id='140667361334032'>, "<Mock name='key' id='140667361334032'>-stored") _error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7fefab84da80>, cause = None def assert_called_with(self, /, *args, **kwargs):
"""assert that the last call was made with the specified arguments.
Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock."""
if self.call_args is None: expected = self._format_mock_call_signature(args, kwargs)
actual = 'not called.'
error_message = ('expected call not found.\nExpected: %s\nActual: %s' % (expected, actual))
raise AssertionError(error_message)
def _error_message():
msg = self._format_mock_failure_message(args, kwargs)
return msg
expected = self._call_matcher(_Call((args, kwargs), two=True))
actual = self._call_matcher(self.call_args)
if actual != expected:
cause = expected if isinstance(expected, Exception) else None
> raise AssertionError(_error_message()) from cause
E AssertionError: expected call not found.
E Expected: mock(<Mock name='key' id='140667361334032'>, 'value')
E Actual: mock(<Mock name='key' id='140667361334032'>, "<Mock name='key' id='140667361334032'>-stored")
Versions
- Python version
3.12
- Faust version
Master
- Operating system
Linux
Checklist
masterbranch of Faust.Steps to reproduce
Try and test with 3.12
Expected behavior
Green tests
Actual behavior
See tracebacks below
Probably related, though the fix doesn't help: miguelgrinberg/python-socketio#1265
Full traceback
After renaming the method with
assert_:tests/unit/tables/test_objects.py:66: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _../../.asdf/installs/python/3.12.0/lib/python3.12/unittest/mock.py:956: in assert_called_once_with return self.assert_called_with(*args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <Mock name='mock.__setitem__' id='140667361335760'>, args = (<Mock name='key' id='140667361334032'>, 'value'), kwargs = {} expected = call(<Mock name='key' id='140667361334032'>, 'value') actual = call(<Mock name='key' id='140667361334032'>, "<Mock name='key' id='140667361334032'>-stored") _error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7fefab84da80>, cause = None def assert_called_with(self, /, *args, **kwargs): """assert that the last call was made with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.""" if self.call_args is None: expected = self._format_mock_call_signature(args, kwargs) actual = 'not called.' error_message = ('expected call not found.\nExpected: %s\nActual: %s' % (expected, actual)) raise AssertionError(error_message) def _error_message(): msg = self._format_mock_failure_message(args, kwargs) return msg expected = self._call_matcher(_Call((args, kwargs), two=True)) actual = self._call_matcher(self.call_args) if actual != expected: cause = expected if isinstance(expected, Exception) else None > raise AssertionError(_error_message()) from cause E AssertionError: expected call not found. E Expected: mock(<Mock name='key' id='140667361334032'>, 'value') E Actual: mock(<Mock name='key' id='140667361334032'>, "<Mock name='key' id='140667361334032'>-stored")Versions
3.12
Master
Linux