GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
No description provided.
Refs #21230 -- removed direct settings manipulation from staticfile t…
I'm not sure we want to change the behavior to store the temporary files somewhere different from os.environ['DJANGO_TEST_TEMP_DIR']?
I think the behavior should change:
Originally, a new temporary directory would be created for every set up, then settings.STATIC_ROOT would be assigned to that directory until it's time to tear down the test. This is incompatible with the way the override_settings decorator should work in principle for classes. That is, the class should be able to specify settings.STATIC_ROOT in the decorator and be done with it, instead of having it change for every test run under that class, which happens if we use the tempfile module to create the directory for us.
Interestingly, changing the behavior to use a fixed directory that is deleted on tearDown by the shutil.rmtree call reveals behavior that is expected but fails TestCollectionDryRun. This is because calling collectstatic as a dry run doesn't even create the directory specified by settings.STATIC_ROOT. The test will check if the directory is empty and fail because there is no directory.
My change creates the directory in setUp to fix the test, but I suspect more testing is probably warranted for TestCollectionDryRun to ensure its behavior never creates a directory when there is none already.
It looks like there's a problem in that staticfiles_tests/project/site_media/static/testfile.txt is left deleted after /runtests.py staticfiles_tests.
Looking through the history of that file, looks like it was originally added here: 1d32bdd3, and then migrated along with the staticfiles_tests directory here: 89f40e36.
I can't speak for why the file was added in the first place, but I suspect it was a way of keeping the site-media/static directory alive for git. When I remove that directory, the (entire) test suite passes for both the original tests and for the tests after my changes, so I don't think it's necessary.
Maybe this file is more important than I think. Perhaps have another pair of eyes take a look at this? I can commit a delete on that file and directory if everything checks out. Otherwise, I can revert the behavior back, and that would keep this file alive.
looks like the setUp() method is no longer needed.
looks like tearDown() is no longer needed.
Remove unused methods
Remove unused file
merged in 949ee52, thanks.