@@ -52,22 +52,17 @@ def test_use_fixture_with_decorator(some_data):
52
52
'assert_frame_equal' ])
53
53
@pytest .mark .parametrize ('pd_version' , ['1.0.0' , '1.1.0' ])
54
54
@pytest .mark .parametrize ('check_less_precise' , [True , False ])
55
- def test__check_pandas_assert_kwargs (mocker , monkeypatch ,
56
- function_name , pd_version ,
55
+ def test__check_pandas_assert_kwargs (mocker , function_name , pd_version ,
57
56
check_less_precise ):
58
57
# test that conftest._check_pandas_assert_kwargs returns appropriate
59
58
# kwargs for the assert_x_equal functions
60
59
61
- # patch the pandas assert; not interested in actually calling them:
62
- def patched_assert (* args , ** kwargs ):
63
- pass
64
-
65
- monkeypatch .setattr (pandas .testing , function_name , patched_assert )
66
- # then attach a spy to it so we can see what args it is called with:
67
- mocked_function = mocker .spy (pandas .testing , function_name )
60
+ # patch the pandas assert; not interested in actually calling them,
61
+ # plus we want to spy on how they get called.
62
+ spy = mocker .patch ('pandas.testing.' + function_name )
68
63
# patch pd.__version__ to exercise the two branches in
69
64
# conftest._check_pandas_assert_kwargs
70
- monkeypatch . setattr ( pandas , ' __version__' , pd_version )
65
+ mocker . patch ( 'pandas. __version__' , new = pd_version )
71
66
72
67
# finally, run the function and check what args got passed to pandas:
73
68
assert_function = getattr (conftest , function_name )
@@ -79,4 +74,4 @@ def patched_assert(*args, **kwargs):
79
74
else :
80
75
expected_kwargs = {'check_less_precise' : check_less_precise }
81
76
82
- mocked_function . assert_called_with (* args , ** expected_kwargs )
77
+ spy . assert_called_once_with (* args , ** expected_kwargs )
0 commit comments