Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 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: UI/UX:

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 (0)

Change History (7)

comment:1 Changed 9 years ago by jacob

  • Owner changed from adrian to jacob

comment:2 Changed 9 years ago by jacob

  • Status changed from new to assigned

comment:3 Changed 9 years ago by adrian

  • milestone set to Version 1.0

comment:4 Changed 9 years ago 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.

comment:5 Changed 9 years ago by jacob

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

comment:6 Changed 9 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:7 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.