Django

Code

Ticket #238 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

Database tests fail with sqlite

Reported by: cthier@gmail.com Assigned to: jacob
Milestone: Component: Database layer (models, ORM)
Version: 1.0 Keywords: sqlite
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I get the following failures when running the database tests (runtests.py) I am using SQLite3 with pysqlite2 v2.0.3 on OS X and Python 2.4

Got 12 errors:

'basic' model: API test failed
==============================
Code: 'a.id'
Line: 13
Expected: '1L\n'
Got: '1\n'

'custom_methods' model: API test failed
=======================================
Code: 'a.get_articles_from_same_day_1()'
Line: 11
Expected: '[Beatles reunite]\n'
Got: '[]\n'

'custom_methods' model: API test failed
=======================================
Code: 'a.get_articles_from_same_day_2()'
Line: 13
Expected: '[Beatles reunite]\n'
Got: '[]\n'

chuck:~/django/tests cthier$ python runtests.py           
Got 12 errors:

'basic' model: API test failed
==============================
Code: 'a.id'
Line: 13
Expected: '1L\n'
Got: '1\n'

'custom_methods' model: API test failed
=======================================
Code: 'a.get_articles_from_same_day_1()'
Line: 11
Expected: '[Beatles reunite]\n'
Got: '[]\n'

'custom_methods' model: API test failed
=======================================
Code: 'a.get_articles_from_same_day_2()'
Line: 13
Expected: '[Beatles reunite]\n'
Got: '[]\n'

'custom_methods' model: API test failed
=======================================
Code: 'b.get_articles_from_same_day_1()'
Line: 15
Expected: '[Area man programs in Python]\n'
Got: '[]\n'

'custom_methods' model: API test failed
=======================================
Code: 'b.get_articles_from_same_day_2()'
Line: 17
Expected: '[Area man programs in Python]\n'
Got: '[]\n'

'lookup' model: API test failed
===============================
Code: 'articles.get_count()'
Line: 26
Expected: '4L\n'
Got: u'4\n'

'lookup' model: API test failed
===============================
Code: 'articles.get_count(pub_date__exact=datetime(2005, 7, 27))'
Line: 28
Expected: '2L\n'
Got: u'2\n'

'lookup' model: API test failed
===============================
Code: "articles.get_count(headline__startswith='Blah blah')"
Line: 30
Expected: '0L\n'
Got: u'0\n'

'many_to_one' model: API test failed
====================================
Code: 'a.reporter_id'
Line: 10
Expected: '1L\n'
Got: '1\n'

'many_to_one' model: API test failed
====================================
Code: 'r.first_name, r.last_name'
Line: 18
Expected: "('John', 'Smith')\n"
Got: "(u'John', u'Smith')\n"

'many_to_one' model: API test failed
====================================
Code: 'r.get_article_count()'
Line: 35
Expected: '2L\n'
Got: '2\n'

'one_to_one' model: API test failed
===================================
Code: 'p2.get_restaurant()'
Line: 20
Expected: "Traceback (most recent call last):\n    ...\nRestaurantDoesNotExist: Restaurant does not exist for {'id__exact': 2L}\n"
Got: 'Traceback (most recent call last):\n  File "/Users/cthier/django/tests/doctest.py", line 1243, in __run\n    compileflags, 1) in test.globs\n  File "<doctest one_to_one[8]>", line 1, in ?\n    p2.get_restaurant()\n  File "/opt/local/lib/python2.4/site-packages/django/core/meta.py", line 87, in _curried\n    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))\n  File "/opt/local/lib/python2.4/site-packages/django/core/meta.py", line 884, in method_get_related\n    return getattr(rel_mod, method_name)(**kwargs)\n  File "/opt/local/lib/python2.4/site-packages/django/core/meta.py", line 87, in _curried\n    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))\n  File "/opt/local/lib/python2.4/site-packages/django/core/meta.py", line 1036, in function_get_object\n    raise does_not_exist_exception, "%s does not exist for %s" % (opts.object_name, kwargs)\nRestaurantDoesNotExist: Restaurant does not exist for {\'id__exact\': 2}\n'   

Attachments

Change History

07/31/05 08:28:10 changed by jacob

  • owner changed from adrian to jacob.

07/31/05 08:28:16 changed by jacob

  • status changed from new to assigned.

08/01/05 14:48:35 changed by adrian

  • milestone set to Version 1.0.

08/08/05 12:54:39 changed by jacob

All the issues now are related to the fact the pg and mysql use longs for any integer field, but sqlite uses ints. I'm not really sure how to fix the fact that "1L" != "1", so perhaps we'll need to patch doctest to take that into account because the distinction doesn't seem too much of a big deal.

08/10/05 13:00:53 changed by jacob

(In [465]) Added a custom doctest OutputChecker? that ignores differences between ints and longs in values returned from the database; refs #238

08/10/05 13:10:39 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [466]) Doctest now uses the ELLIPSIS option, which allows the one_to_one test to pass under sqlite. This fixes #238.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted


Add/Change #238 (Database tests fail with sqlite)




Change Properties
Action