Changes between Version 1 and Version 2 of DjangoOnWindows


Ignore:
Timestamp:
Jun 29, 2008, 6:51:26 PM (16 years ago)
Author:
Ramiro Morales
Comment:

Update with details about sqlite-related test suite failure on win32

Legend:

Unmodified
Added
Removed
Modified
  • DjangoOnWindows

    v1 v2  
    33(work in progress)
    44
     5[[TOC]]
     6
    57== Test suite failures ==
    68
    7 As of r7787 the test suite is failing in two places when run under Windows:
     9As of r7787 the test suite is failing in two places when run on Windows + Python 2.5.2:
    810
    9  * If setuptools is installed, on a test from {{{tests/regressiontests/templates/loaders.py}}} related to trying to load a template from an egg (from a report on #django-dev, this is a test that is also failing under OS X).
    10  * On a date-related query from ({{{tests/regressiontests/queries/models.py}}}) when using the sqlite3 Django DB backend under Pyhton 2.5.2
     11 * If setuptools is installed, on a test from {{{tests/regressiontests/templates/loaders.py}}} related to trying to load a template from an egg (from a report on #django-dev, it seems this is a test that is also failing on OS X).
     12 * On a test query from ({{{tests/regressiontests/queries/models.py}}}) when using the sqlite3 Django DB backend
    1113
    1214=== tests/regressiontests/templates/loaders.py ===
     
    1618=== tests/regressiontests/queries/models.py ===
    1719
    18 This test:
     20This test from {{{tests/regressiontests/queries/models.py}}} fails when running test suite:
    1921
    2022{{{
     
    2527}}}
    2628
    27 from {{{tests/regressiontests/queries/models.py}}} fails.
     29Error is:
     30
     31{{{
     32======================================================================
     33FAIL: Doctest: regressiontests.queries.models.__test__.API_TESTS
     34----------------------------------------------------------------------
     35Traceback (most recent call last):
     36  File "C:\ramiro\django-trunk\django\test\_doctest.py", line 2180, in runTest
     37    raise self.failureException(self.format_failure(new.getvalue()))
     38AssertionError: Failed doctest test for regressiontests.queries.models.__test__.API_TESTS
     39  File "C:\ramiro\django-trunk\tests\regressiontests\queries\models.py", line unknown line number, in API_TESTS
     40
     41----------------------------------------------------------------------
     42File "C:\ramiro\django-trunk\tests\regressiontests\queries\models.py", line ?, in regressiontests.queries.models.__test__.API_TESTS
     43Failed example:
     44    Item.objects.dates('created', 'day').extra(select={'a': 1})
     45Exception raised:
     46    Traceback (most recent call last):
     47      File "C:\ramiro\django-trunk\django\test\_doctest.py", line 1267, in __run
     48        compileflags, 1) in test.globs
     49      File "<doctest regressiontests.queries.models.__test__.API_TESTS[169]>", line 1, in <module>
     50        Item.objects.dates('created', 'day').extra(select={'a': 1})
     51      File "c:\ramiro\django-trunk\django\db\models\query.py", line 129, in __repr__
     52        return repr(list(self))
     53      File "c:\ramiro\django-trunk\django\db\models\query.py", line 141, in __len__
     54        self._result_cache.extend(list(self._iter))
     55      File "c:\ramiro\django-trunk\django\db\models\sql\subqueries.py", line 351, in results_iter
     56        for rows in self.execute_sql(MULTI):
     57      File "c:\ramiro\django-trunk\django\db\models\sql\query.py", line 1607, in execute_sql
     58        cursor.execute(sql, params)
     59      File "c:\ramiro\django-trunk\django\db\backends\sqlite3\base.py", line 136, in execute
     60        return Database.Cursor.execute(self, query, params)
     61    OperationalError: ORDER BY terms must not be non-integer constants
     62
     63
     64----------------------------------------------------------------------
     65Ran 253 tests in 433.032s
     66
     67FAILED (failures=1)
     68}}}
    2869
    2970This is a minimal models.py that shows the problem (extracted from the above regression test):
     
    65106}}}
    66107
    67 
    68 
    69108The SQL being generated by Django is correct:
    70109
     
    75114}}}
    76115
    77 Problems seems to be related to some bug in the version of pysqlite2 or sqlite3 (most likely suspect) included with the official Python 2.5.2 win32 installer (2.3.2 and 3.3.4 respectively):
     116Problems seems to be related to some bug in the version of pysqlite2 or sqlite3 (main suspect) included with the official Python 2.5.2 win32 installer (2.3.2 and 3.3.4 respectively):
    78117
    79118{{{
     
    88127}}}
    89128
    90 The same test works flawlessly under the following platforms:
     129The same test works flawlessly on the following platforms:
    91130 * GNU/Debian Linux 4.0 (Python 2.4.4 + pysqlite2 2.3.2 + sqlite3 3.3.8)
    92  * GNU/Debian Linux Sid as of Jun 29, 2008 (Python 2.5.2 + builtin pysqlite2 aka sqlite3 2.3.2 + sqlite 3.5.9)
    93 this may be thanks to the fact that on these platforms the shared sqlite3 library being used by the Python pysqlite2 (Python 2.4) or sqlite3 (Python 2.5) modules is the system wide one and so it hasn't been frozen on 3.3.4.
     131 * GNU/Debian Linux Sid as of Jun 29, 2008 (Python 2.5.2 + builtin pysqlite2 aka sqlite3 2.3.2 + sqlite3 3.5.9)
     132this may be thanks to the fact that on these platforms the shared sqlite3 library being used by the pysqlite2 (Python 2.4) or sqlite3 (Python 2.5) Python modules is the system wide one and so it hasn't been frozen at 3.3.4.
    94133
    95134==== Possible solution ====
    96135
    97 The pysqlite project keeps publishing win32 binary installer for Python 2.5.
     136As sqlite/pysqlite development continues, the pysqlite project keeps publishing new win32 binary installers for Python 2.5. Latest as of today June 29, 2008 is version 2.4.1 ({{{pysqlite-2.4.1.win32-py2.5.exe}}}) that uses sqlite version 3.5.2:
    98137
    99 TBD
     138{{{
     139#!python
     140>>> from pysqlite2 import dbapi2
     141>>> print dbapi2.version_info
     142(2, 4, 1)
     143>>> print dbapi2.sqlite_version_info
     144(3, 5, 2)
     145>>>
     146}}}
     147
     148The error doesn't show itself when running the tests if one manages to force Django to use this newer version of pysqlite (see below). This seems to indicate that something was fixed on sqlite between versions 3.3.4 and 3.5.2 (see http://sqlite.org/changes.html).
     149
     150==== How does this affect Django ====
     151
     152The problem doesn't lie with Django, but leads to ask if the order being used to try loading the sqlite-related DB-API2 modules by the sqlite3 backed ({{{django/db/backends/sqlite3/base.py}}}) shouldn't be inverted: Try loading pysqlite2 first and if it fails then try loading sqlite3:
     153
     154{{{
     155#!diff
     156--- base.py     2008-04-27 00:58:35.000000000 -0300
     157+++ base.py-proposed    2008-06-29 20:48:29.000000000 -0300
     158@@ -3,15 +3,16 @@
     159 
     160 Python 2.3 and 2.4 require pysqlite2 (http://pysqlite.org/).
     161 
     162-Python 2.5 and later use the sqlite3 module in the standard library.
     163+Python 2.5 and later use pysqlite2 or the sqlite3 module in the standard
     164+library.
     165 """
     166 
     167 from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures, BaseDatabaseOperations, util
     168 try:
     169     try:
     170-        from sqlite3 import dbapi2 as Database
     171-    except ImportError:
     172         from pysqlite2 import dbapi2 as Database
     173+    except ImportError:
     174+        from sqlite3 import dbapi2 as Database
     175 except ImportError, e:
     176     import sys
     177     from django.core.exceptions import ImproperlyConfigured
     178}}}
     179
     180Reasoning behind this is that this would allow the user to take advantage of newer pysqlite2/sqlite3 versions he/she may have installed even if using Python 2.5. This might be true regardless of the platform.
    100181
    101182== See also ==
Back to Top