def test_returns_false_if_not_all_files_are_opened(self): with create_mock_can_open() as can_open: can_open.return_value = False self.assertFalse(utils.can_open_all([ "/some/path/a", "/some/path/b", ]))
def test_returns_true_if_all_files_are_openable(self): with create_mock_can_open(): self.assertTrue( utils.can_open_all([ "/some/path/a", "/some/path/b", ]))
def test_only_call_can_open_as_many_times_as_needed(self): with create_mock_can_open() as can_open: can_open.side_effect = [True, False, True] self.assertFalse(utils.can_open_all([ "/can/open", "/cannot/open", "/can/open", ])) self.assertEqual(can_open.call_count, 2)
def test_returns_true_if_all_files_are_openable(self): with create_mock_can_open(): self.assertTrue(utils.can_open_all(["/some/path/a", "/some/path/b"]))