class FileSystemTestCase(TestCase): def setup_method(self, method): TestCase.setup_method(self, method) self.path = os.path.join( os.path.dirname(__file__), 'uploads', 'images' ) self.rel_path = os.path.join('uploads', 'images') self.storage = FileSystemStorage(os.path.dirname(__file__)) self.file = 'some_file.txt' def teardown_method(self, method): shutil.rmtree(os.path.join( os.path.dirname(__file__), 'uploads' ), ignore_errors=True) try: self.storage.delete(self.file) except StorageException: pass
def test_raises_exception_for_unknown_file(self): storage = FileSystemStorage(os.path.dirname(__file__)) with raises(StorageException): storage.delete('some_unknown_file')