def test_cache_file_object(self, mock_start, mock_open): cache = Cache('test') handle = open('handle', 'w') fileobj = ['line1', 'line2', 'line3'] cache._cache_file_contents(handle, fileobj) self.assertEquals(3, mock_open().write.call_count)