def test_file_is_used_directly_when_opened_file_is_given(self): file = mock.Mock() f = File(file) f.read() file.read.assert_called_once_with()
def test_file_is_opened_when_path_is_given(self, open): file = mock.Mock() open.return_value = file f = File('test.txt') f.read() open.assert_called_once_with('test.txt', 'rb') file.read.assert_called_once_with()
def test_file_is_used_directly_when_opened_file_is_given(self): file = mock.Mock() f = File(file) f.read() file.read.assert_called_once_with()
def test_file_is_opened_when_path_is_given(self, open): file = mock.Mock() open.return_value = file f = File('test.txt') f.read() open.assert_called_once_with('test.txt', 'rb') file.read.assert_called_once_with()