You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
called_with is an incorrect method that just returns a Mock object that evaluates to True and doesn't perform appropriate assertion. This method should be replaced with assert_called_with . Related CPython issue : python/cpython#100690 . Changes cause below test failures.
pytest tests/test_core.py
==================================================================== test session starts =====================================================================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0
rootdir: /root/checked_repos_clone_3900_4000/datacompy, configfile: pytest.ini
plugins: cov-2.12.1
collected 81 items
tests/test_core.py .............................FF.................................................. [100%]
========================================================================== FAILURES ==========================================================================
________________________________________________________________________ test_subset _________________________________________________________________________
mock_debug = <MagicMock name='debug' id='140448511508688'>
@mock.patch("datacompy.logging.debug")
def test_subset(mock_debug):
df1 = pd.DataFrame([{"a": 1, "b": 2, "c": "hi"}, {"a": 2, "b": 2, "c": "yo"}])
df2 = pd.DataFrame([{"a": 1, "c": "hi"}])
comp = datacompy.Compare(df1, df2, ["a"])
assert comp.subset()
> mock_debug.assert_called_with("Checking equality")
tests/test_core.py:529:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='debug' id='140448511508688'>, args = ('Checking equality',), kwargs = {}, expected = "debug('Checking equality')"
actual = 'not called.', error_message = "expected call not found.\nExpected: debug('Checking equality')\nActual: not called."
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)
E AssertionError: expected call not found.
E Expected: debug('Checking equality')
E Actual: not called.
/usr/lib/python3.11/unittest/mock.py:924: AssertionError
______________________________________________________________________ test_not_subset _______________________________________________________________________
mock_info = <MagicMock name='info' id='140448491660176'>
@mock.patch("datacompy.logging.info")
def test_not_subset(mock_info):
df1 = pd.DataFrame([{"a": 1, "b": 2, "c": "hi"}, {"a": 2, "b": 2, "c": "yo"}])
df2 = pd.DataFrame([{"a": 1, "b": 2, "c": "hi"}, {"a": 2, "b": 2, "c": "great"}])
comp = datacompy.Compare(df1, df2, ["a"])
assert not comp.subset()
> mock_info.assert_called_with("Sample c mismatch: a: 2, df1: yo, df2: great")
tests/test_core.py:538:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='info' id='140448491660176'>, args = ('Sample c mismatch: a: 2, df1: yo, df2: great',), kwargs = {}
expected = "info('Sample c mismatch: a: 2, df1: yo, df2: great')", actual = 'not called.'
error_message = "expected call not found.\nExpected: info('Sample c mismatch: a: 2, df1: yo, df2: great')\nActual: not called."
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)
E AssertionError: expected call not found.
E Expected: info('Sample c mismatch: a: 2, df1: yo, df2: great')
E Actual: not called.
/usr/lib/python3.11/unittest/mock.py:924: AssertionError
====================================================================== warnings summary ======================================================================
../../checked_repos/taskcat/.env/lib/python3.11/site-packages/_pytest/config/__init__.py:1294
/root/checked_repos/taskcat/.env/lib/python3.11/site-packages/_pytest/config/__init__.py:1294: PytestConfigWarning: Unknown config option: spark_options
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
tests/test_core.py:29
/root/checked_repos_clone_3900_4000/datacompy/tests/test_core.py:29: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
from pandas.util.testing import assert_series_equal
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================== short test summary info ===================================================================
FAILED tests/test_core.py::test_subset - AssertionError: expected call not found.
FAILED tests/test_core.py::test_not_subset - AssertionError: expected call not found.
========================================================== 2 failed, 79 passed, 2 warnings in 1.69s ==========================================================
The text was updated successfully, but these errors were encountered:
called_with
is an incorrect method that just returns a Mock object that evaluates to True and doesn't perform appropriate assertion. This method should be replaced with assert_called_with . Related CPython issue : python/cpython#100690 . Changes cause below test failures.The text was updated successfully, but these errors were encountered: