#7745 closed (fixed)
admin_scripts tests use assertTrue, not there in Python 2.3
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
With the fix r7921 (thanks) I got past the immediate error on trying to run tests on 2.3, but hit a few more.
First the admin_scripts tests assume unittest.TestCase has an assertTrue method, but that doesn't exist in 2.3. Looking at the source it seems failUnless, which does exist in 2.3, is the same as assertTrue. Changing assertTrue to failUnless allows all the admin_scripts tests to run successfully on Python 2.3.
Second the regressiontests/utils/datastructures.py file attempts to work around the lack of sorted in 2.3 but the import is at the end of the file, which doesn't seem to work. Moving it to the top allows that test to run.
There are a couple of more failures running on 2.3 but they are unrelated to admin_scripts or sorted and I've run out of time for now so I figured I'd get these ones submitted and fixed first.
Attachments (2)
Change History (12)
by , 16 years ago
Attachment: | 23compat.diff added |
---|
comment:1 by , 16 years ago
Has patch: | set |
---|
comment:2 by , 16 years ago
follow-up: 4 comment:3 by , 16 years ago
The second part of this patch is problematic. Yes, the tests pass if you move the import to the top of the page - that's because the datastructures test isn't running any more :-)
The current setup relies upon the fact that the datastructures module has a module docstring, which means there can't be any code preceeding the docstring. There are a few other ways to restructure this test (using imports or a test variable), but I don't have a version of Python 2.3 on hand to validate these potential fixes.
comment:4 by , 16 years ago
Replying to russellm:
The second part of this patch is problematic. Yes, the tests pass if you move the import to the top of the page - that's because the datastructures test isn't running any more :-)
Ha! Oops.
The current setup relies upon the fact that the datastructures module has a module docstring, which means there can't be any code preceeding the docstring. There are a few other ways to restructure this test (using imports or a test variable), but I don't have a version of Python 2.3 on hand to validate these potential fixes.
Feel free to send me potential fixes and I can test them for you, since I went and got 2.3 for one of my boxes specifically to test Django on 2.3.
by , 16 years ago
Attachment: | 7745-part_b.diff added |
---|
Potential patch for part b of issue report; NOTE: intentional failure in first test
comment:5 by , 16 years ago
I've just attached a fix that works on my install. Note that I have intentionally broken one of the datastructures tests so you can be certain that the test is running.
comment:6 by , 16 years ago
I don't think it works...I still get a sorted failure (plus the new intentional failure):
D:\u\kmt\django\trunk\tests>\bin\Python2.3.5\python.exe runtests.py --settings=testsettings utils ====================================================================== FAIL: Doctest: regressiontests.utils.tests.__test__.datastructures ---------------------------------------------------------------------- Traceback (most recent call last): File "d:\u\kmt\django\trunk\django\test\_doctest.py", line 2180, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for regressiontests.utils.tests.__test__.datastructures File "D:\u\kmt\django\trunk\tests\regressiontests\utils\tests.py", line unknown line number, in datastructures ---------------------------------------------------------------------- File "D:\u\kmt\django\trunk\tests\regressiontests\utils\tests.py", line ?, in regressiontests.utils.tests.__test__.datastructures Failed example: d.keys() Expected: [7, 1, 9xxxxxxxx] Got: [7, 1, 9] ---------------------------------------------------------------------- File "D:\u\kmt\django\trunk\tests\regressiontests\utils\tests.py", line ?, in regressiontests.utils.tests.__test__.datastructures Failed example: sorted(real_dict.values()) Exception raised: Traceback (most recent call last): File "d:\u\kmt\django\trunk\django\test\_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest regressiontests.utils.tests.__test__.datastructures[23]>", line 1, in ? sorted(real_dict.values()) NameError: name 'sorted' is not defined ---------------------------------------------------------------------- Ran 11 tests in 1.662s FAILED (failures=1)
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I think Malcolm fixed this in [8055]. Reopen if I'm wrong.
comment:8 by , 16 years ago
Confirmed fixed with r8057. To avoid confusion, might want to remove the sorted import attempt in tests/regressiontests/utils/datastructures.py, since it's really the one in tests/regressiontests/utils/tests.py that does the trick?
(in [7941]) Refs #7745 -- Modified use of assertTrue to failUnless, because assertTrue isn't available in Python 2.3. Thanks to Karen Tracey for the report and patch.