def test_clear_context(self): with BackupEditAndRestore(self._context_name, self._existing_path, 'w+', suffix=self._suffix): pass with BackupEditAndRestore(self._context_name, self._inexistant_path, 'w+', suffix=self._suffix): pass self.assertTrue(os.path.isfile(self._existing_path)) self.assertTrue(os.path.isfile(self._existing_backup_path)) self.assertFalse(os.path.isfile(self._existing_new_path)) self.assertTrue(os.path.isfile(self._inexistant_path)) self.assertFalse(os.path.isfile(self._inexistant_backup_path)) self.assertFalse(os.path.isfile(self._inexistant_new_path)) BackupEditAndRestore.clear_context(self._context_name) self.assertTrue(os.path.isfile(self._existing_path)) self.assertFalse(os.path.isfile(self._existing_backup_path)) self.assertFalse(os.path.isfile(self._existing_new_path)) self.assertFalse(os.path.isfile(self._inexistant_path)) self.assertFalse(os.path.isfile(self._inexistant_backup_path)) self.assertFalse(os.path.isfile(self._inexistant_new_path))
def test_clear_context_on_non_existant_context(self): self.assertNotIn('some non-existant context', BackupEditAndRestore._contexts) BackupEditAndRestore.clear_context('some non-existant context')