(self)
| 481 | """ |
| 482 | |
| 483 | def setUp(self): |
| 484 | self.temp_dir = tempfile.mkdtemp() |
| 485 | self.addCleanup(shutil.rmtree, self.temp_dir) |
| 486 | |
| 487 | # get modification and access times for no_label/static/file2.txt |
| 488 | self.orig_path = os.path.join( |
| 489 | TEST_ROOT, "apps", "no_label", "static", "file2.txt" |
| 490 | ) |
| 491 | self.orig_mtime = os.path.getmtime(self.orig_path) |
| 492 | self.orig_atime = os.path.getatime(self.orig_path) |
| 493 | |
| 494 | # prepare duplicate of file2.txt from a temporary app |
| 495 | # this file will have modification time older than |
| 496 | # no_label/static/file2.txt anyway it should be taken to STATIC_ROOT |
| 497 | # because the temporary app is before 'no_label' app in installed apps |
| 498 | self.temp_app_path = os.path.join(self.temp_dir, "staticfiles_test_app") |
| 499 | self.testfile_path = os.path.join(self.temp_app_path, "static", "file2.txt") |
| 500 | |
| 501 | os.makedirs(self.temp_app_path) |
| 502 | with open(os.path.join(self.temp_app_path, "__init__.py"), "w+"): |
| 503 | pass |
| 504 | |
| 505 | os.makedirs(os.path.dirname(self.testfile_path)) |
| 506 | with open(self.testfile_path, "w+") as f: |
| 507 | f.write("duplicate of file2.txt") |
| 508 | |
| 509 | os.utime(self.testfile_path, (self.orig_atime - 1, self.orig_mtime - 1)) |
| 510 | |
| 511 | settings_with_test_app = self.modify_settings( |
| 512 | INSTALLED_APPS={"prepend": "staticfiles_test_app"}, |
| 513 | ) |
| 514 | with extend_sys_path(self.temp_dir): |
| 515 | settings_with_test_app.enable() |
| 516 | self.addCleanup(settings_with_test_app.disable) |
| 517 | super().setUp() |
| 518 | |
| 519 | def test_ordering_override(self): |
| 520 | """ |
nothing calls this directly
no test coverage detected