Opened 16 years ago
Closed 16 years ago
#7847 closed (fixed)
[Cleanup] Unused imported modules in Django
Reported by: | Julien Phalip | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | cleanup | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I've removed many import statements of modules that were not used, throughout Django (see patch attached). That won't necessarily improve performance but it's a good cleanup at least. I ran the full test suite several times. I do get some failures/errors but I don't think they're linked to the changes in the patch since I get the exact same errors from a clean check out. My test environment (based on Windows XP+MySQL) is probably not 100% reliable and there might also be some problems caused by the latest big changes in trunk. Just for the record, here is a sample of the failures/errors I get:
====================================================================== FAIL: Doctest: modeltests.delete.models.__test__.API_TESTS ---------------------------------------------------------------------- Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 2180, in run Test raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for modeltests.delete.models.__test__.API_TE STS File "E:\Software\workspace\django-clean\tests\modeltests\delete\models.py", l ine unknown line number, in API_TESTS ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\modeltests\delete\models.py", lin e ?, in modeltests.delete.models.__test__.API_TESTS Failed example: del D._meta._related_objects_cache Exception raised: Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest modeltests.delete.models.__test__.API_TESTS[17]>", line 1, in <module> del D._meta._related_objects_cache AttributeError: _related_objects_cache ====================================================================== FAIL: Doctest: regressiontests.string_lookup.models.__test__.API_TESTS ---------------------------------------------------------------------- Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 2180, in run Test raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for regressiontests.string_lookup.models.__t est__.API_TESTS File "E:\Software\workspace\django-clean\tests\regressiontests\string_lookup\m odels.py", line unknown line number, in API_TESTS ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\string_lookup\mod els.py", line ?, in regressiontests.string_lookup.models.__test__.API_TESTS Failed example: Foo.objects.get(friend__contains=u'\xe7') Exception raised: Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest regressiontests.string_lookup.models.__test__.API_TESTS[18] >", line 1, in <module> Foo.objects.get(friend__contains=u'\xe7') File "E:\Software\workspace\django\django\db\models\manager.py", line 82, in get return self.get_query_set().get(*args, **kwargs) File "E:\Software\workspace\django\django\db\models\query.py", line 302, i n get % self.model._meta.object_name) DoesNotExist: Foo matching query does not exist. ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\string_lookup\mod els.py", line ?, in regressiontests.string_lookup.models.__test__.API_TESTS Failed example: Foo.objects.get(friend__contains='\xc3\xa7') Exception raised: Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest regressiontests.string_lookup.models.__test__.API_TESTS[19] >", line 1, in <module> Foo.objects.get(friend__contains='\xc3\xa7') File "E:\Software\workspace\django\django\db\models\manager.py", line 82, in get return self.get_query_set().get(*args, **kwargs) File "E:\Software\workspace\django\django\db\models\query.py", line 302, i n get % self.model._meta.object_name) DoesNotExist: Foo matching query does not exist. ====================================================================== FAIL: Doctest: regressiontests.model_inheritance_regress.models.__test__.API_TES TS ---------------------------------------------------------------------- Traceback (most recent call last): File "E:\Software\workspace\django\django\test\_doctest.py", line 2180, in run Test raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for regressiontests.model_inheritance_regres s.models.__test__.API_TESTS File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritan ce_regress\models.py", line unknown line number, in API_TESTS ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritance _regress\models.py", line ?, in regressiontests.model_inheritance_regress.models .__test__.API_TESTS Failed example: [sorted(d.items()) for d in dicts] Expected: [[('name', u"Guido's House of Pasta"), ('serves_hot_dogs', True)]] Got: [[('name', u"Guido's House of Pasta"), ('serves_hot_dogs', 1)]] ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritance _regress\models.py", line ?, in regressiontests.model_inheritance_regress.models .__test__.API_TESTS Failed example: [sorted(d.items()) for d in dicts] Expected: [[('name', u"Guido's House of Pasta"), ('serves_gnocchi', True), ('serves_ho t_dogs', True)]] Got: [[('name', u"Guido's House of Pasta"), ('serves_gnocchi', 1), ('serves_hot_d ogs', 1)]] ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritance _regress\models.py", line ?, in regressiontests.model_inheritance_regress.models .__test__.API_TESTS Failed example: [sorted(d.items()) for d in dicts] Expected: [[('name', u"Guido's All New House of Pasta"), ('serves_hot_dogs', False)]] Got: [[('name', u"Guido's All New House of Pasta"), ('serves_hot_dogs', 0)]] ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritance _regress\models.py", line ?, in regressiontests.model_inheritance_regress.models .__test__.API_TESTS Failed example: [sorted(d.items()) for d in dicts] Expected: [[('name', u"Guido's All New House of Pasta"), ('serves_gnocchi', False), (' serves_hot_dogs', False)]] Got: [[('name', u"Guido's All New House of Pasta"), ('serves_gnocchi', 0), ('serv es_hot_dogs', 0)]] ---------------------------------------------------------------------- File "E:\Software\workspace\django-clean\tests\regressiontests\model_inheritance _regress\models.py", line ?, in regressiontests.model_inheritance_regress.models .__test__.API_TESTS Failed example: [sorted(d.items()) for d in dicts] Expected: [[('name', u"Guido's All New House of Pasta"), ('serves_gnocchi', False), (' serves_hot_dogs', False)]] Got: [[('name', u"Guido's All New House of Pasta"), ('serves_gnocchi', 0), ('serv es_hot_dogs', 0)]] ---------------------------------------------------------------------- Ran 406 tests in 3574.203s FAILED (failures=5, errors=6)
Attachments (3)
Change History (7)
by , 16 years ago
Attachment: | unused.imports.diff added |
---|
by , 16 years ago
Attachment: | unused.imports.r8002.diff added |
---|
comment:1 by , 16 years ago
From the error messages above, I just realised that there's a mix up between 2 checkouts of django (in the test errors, not the patch), so I'll try to run another test suite today and will post an update here. Feel free to give it a shot on your own test environment too.
comment:2 by , 16 years ago
Ok, I really struggled to run the whole test suite. I tried multiple times and consistently get some errors and failures. Some originate from known issues in Windows [1], and others I really don't understand why I get them (e.g. all the Permission Denied ones).
My environment is apparently not the best to run the tests. If you're keen, you can run the tests and see if the patch doesn't break anything. Feel free to close and wontfix the ticket if you feel it's not worth it.
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
First patch was not rendered properly