Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#238 closed defect (fixed)

Database tests fail with sqlite

Reported by: cthier@… Owned by: Jacob
Component: Database layer (models, ORM) Version: 1.0
Severity: normal Keywords: sqlite
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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'   

Change History (7)

comment:1 by Jacob, 19 years ago

Owner: changed from Adrian Holovaty to Jacob

comment:2 by Jacob, 19 years ago

Status: newassigned

comment:3 by Adrian Holovaty, 19 years ago

milestone: Version 1.0

comment:4 by Jacob, 19 years ago

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.

comment:5 by Jacob, 19 years ago

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

comment:6 by Jacob, 19 years ago

Resolution: fixed
Status: assignedclosed

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

comment:7 by (none), 18 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top