def test(self): parent_path = lambda _:None class MyVolumes: def volume_of(self, _path): return '/volume' volumes = MyVolumes() realpath = lambda _: None fs = Mock(['move', 'atomic_write', 'remove_file', 'ensure_dir', 'isdir', 'islink', 'has_sticky_bit']) fs.islink.side_effect = lambda path: { '/volume/.Trash':False }[path] fs.has_sticky_bit.side_effect = lambda path: { '/volume/.Trash':False }[path] reporter = Mock(['volume_of_file', 'found_unsecure_trash_dir_unsticky', 'trash_dir_with_volume', 'file_has_been_trashed_in_as']) trashcan = TrashPutCmd(stdout=None, stderr=None, environ={}, volumes=volumes, fs=fs, getuid=lambda: 'uid', now=datetime.now, parent_path=parent_path, realpath=realpath) trashcan.reporter = reporter trashcan.ignore_missing = False trashcan.logger = Mock() trashcan.trash('') assert [ call('', '/volume/.Trash-uid') ] == reporter.file_has_been_trashed_in_as.mock_calls