multiple_database test fails under Python 2.6
When executed under Python 2.6, The multiple_database.QueriesTest.test_subquery test fails:
======================================================================
FAIL: Make sure as_sql works with subqueries and master/slave.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/rkm/projects/django/hg/tests/regressiontests/multiple_database/tests.py", line 886, in test_subquery
self.assertRaises(ValueError, list, qs)
AssertionError: ValueError not raised
----------------------------------------------------------------------
Ran 1 test in 0.008s
FAILED (failures=1)
Change History
(3)
Triage Stage: |
Unreviewed → Accepted
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
The problem appears to (yet again) a weird inconsistency introduced by Python 2.6. Python 2.6 swallows all exceptions raised by len, and list() (which is used in this test case) calls len() early in the test process. As a result, the ValueError that is raised when _as_sql() is invoked on the subquery is never surfaced, and the test passes.
The fix is to correct the test case to use a method other than list() to force evaluation of the test case.