@@ -55,28 +55,30 @@ def ls(cls, path):
55
55
56
56
@pytest .fixture
57
57
def check_unix_fs_mocked (tmpdir , mock ):
58
- def check (mocked_rm ):
59
- (tmpdir / 'foo.txt' ).ensure ()
60
- UnixFS .rm (tmpdir / 'foo.txt' )
61
- os .remove .assert_called_once_with (tmpdir / 'foo.txt' )
62
- mocked_rm .assert_called_once_with (tmpdir / 'foo.txt' )
63
- assert os .path .isfile (str (tmpdir / 'foo.txt' ))
58
+ def check (mocked_rm , mocked_ls ):
59
+ file_name = tmpdir / 'foo.txt'
60
+ file_name .ensure ()
61
+ UnixFS .rm (str (file_name ))
62
+ os .remove .assert_called_once_with (str (file_name ))
63
+ mocked_rm .assert_called_once_with (str (file_name ))
64
+ assert os .path .isfile (str (file_name ))
64
65
mock .stopall ()
65
- UnixFS .rm (str (tmpdir / 'foo.txt' ))
66
- assert not os .path .isfile (str (tmpdir / 'foo.txt' ))
66
+ UnixFS .rm (str (file_name ))
67
+ assert not os .path .isfile (str (file_name ))
67
68
68
69
return check
69
70
70
71
71
72
def mock_using_patch_object (mock ):
72
- return mock .patch .object (os , 'remove' )
73
+ return mock .patch .object (os , 'remove' ), mock .patch .object (os , 'listdir' )
74
+
73
75
74
76
def mock_using_patch (mock ):
75
- return mock .patch ('os.remove' )
77
+ return mock .patch ('os.remove' ), mock .patch ('os.listdir' )
78
+
76
79
77
80
@pytest .mark .parametrize ('mock_fs' , [mock_using_patch_object , mock_using_patch ],
78
81
)
79
82
def test_fixture (mock_fs , mock , check_unix_fs_mocked ):
80
- mocked_rm = mock_fs (mock )
81
- #mocked_rm = mock.patch(os, 'remove')
82
- check_unix_fs_mocked (mocked_rm )
83
+ mocked_rm , mocked_ls = mock_fs (mock )
84
+ check_unix_fs_mocked (mocked_rm , mocked_ls )
0 commit comments