def write(self): """ Update the last run time on the project for each file to the current time. Using this object as a contextmanager is preferred (that will automatically call this method on exit). """ for file_name in self.data: self.data[file_name] = self.current_time pickle_dump( self.log_printer, self.project_dir, {"time": self.current_time, "files": self.data})
def write(self): """ Update the last run time on the project for each file to the current time. Using this object as a contextmanager is preferred (that will automatically call this method on exit). """ for file_name in self.data: self.data[file_name] = self.current_time pickle_dump(self.log_printer, self.project_dir, { "time": self.current_time, "files": self.data })
def test_time_travel(self): cache = FileCache(self.log_printer, 'coala_test2', flush_cache=True) cache.track_files({'file.c'}) cache.write() self.assertTrue('file.c' in cache.data) cache_data = pickle_load(self.log_printer, 'coala_test2', {}) # Back to the future :) cache_data['time'] = 2000000000 pickle_dump(self.log_printer, 'coala_test2', cache_data) cache = FileCache(self.log_printer, 'coala_test2', flush_cache=False) self.assertFalse('file.c' in cache.data)
def test_time_travel(self): cache = FileCache(self.log_printer, "coala_test2", flush_cache=True) cache.track_files({"file.c"}) cache.write() self.assertTrue("file.c" in cache.data) cache_data = pickle_load(self.log_printer, "coala_test2", {}) # Back to the future :) cache_data["time"] = 2000000000 pickle_dump(self.log_printer, "coala_test2", cache_data) cache = FileCache(self.log_printer, "coala_test2", flush_cache=False) self.assertFalse("file.c" in cache.data)
def write(self): """ Update the last run time on the project for each file to the current time. Using this object as a contextmanager is preferred (that will automatically call this method on exit). """ for file in self.to_untrack: if file in self.data: del self.data[file] for file_name in self.data: self.data[file_name] = self.current_time pickle_dump( None, self.project_dir, {'time': self.current_time, 'files': self.data})
def write(self): """ Update the last run time on the project for each file to the current time. Using this object as a contextmanager is preferred (that will automatically call this method on exit). """ for file in self.to_untrack: if file in self.data: del self.data[file] for file_name in self.data: self.data[file_name] = self.current_time pickle_dump(None, self.project_dir, { 'time': self.current_time, 'files': self.data })
def test_permission_error(self, makedirs): makedirs.side_effect = PermissionError self.assertEqual(get_data_path(self.log_printer, "test"), None) self.assertFalse(pickle_dump(self.log_printer, "test", {"answer": 42}))
def test_delete_files(self): pickle_dump(self.log_printer, "coala_test", {"answer": 42}) self.assertTrue(delete_files(self.log_printer, ["coala_test"])) self.assertFalse( os.path.isfile(get_data_path(self.log_printer, "coala_test")))
def test_delete_files(self): pickle_dump(self.log_printer, "coala_test", {"answer": 42}) self.assertTrue(delete_files( self.log_printer, ["coala_test"])) self.assertFalse(os.path.isfile(get_data_path( self.log_printer, "coala_test")))
def test_delete_files(self): pickle_dump(self.log_printer, 'coala_test', {'answer': 42}) self.assertTrue(delete_files( self.log_printer, ['coala_test'])) self.assertFalse(os.path.isfile(get_data_path( self.log_printer, 'coala_test')))
def test_delete_files(self): pickle_dump(self.log_printer, 'coala_test', {'answer': 42}) self.assertTrue(delete_files(self.log_printer, ['coala_test'])) self.assertFalse( os.path.isfile(get_data_path(self.log_printer, 'coala_test')))