FileSystemDjangoTestCase (New in 1.3.0)ΒΆ
FileSystemDjangoTestCase has a tear down method to delete all test files generated by tests, to avoid letting trash in the file system:
class MyTests(FileSystemDjangoTestCase):
def test_x(self):
print(dir(self))
It also has a collection of methods to simplify tests that use files, like:
- create_temp_directory
- remove_temp_directory
- create_temp_file
- create_temp_file_with_name
- rename_temp_file
- remove_temp_file
- copy_file_to_dir
- add_text_to_file
- get_directory_of_the_file
- get_filename
- get_filepath
- get_content_of_file
- create_django_file_with_temp_file
- create_django_file_using_file
It also contains a set of assertion methods:
- assertFileExists
- assertFileDoesNotExists
- assertDirectoryExists
- assertDirectoryDoesNotExists
- assertDirectoryContainsFile
- assertDirectoryDoesNotContainsFile
- assertFilesHaveEqualLastModificationTimestamps
- assertFilesHaveNotEqualLastModificationTimestamps
- assertNumberOfFiles