1
0
mirror of https://github.com/django/django.git synced 2025-07-05 02:09:13 +00:00

[soc2010/test-refactor] updated custom_pk modeltest to take advantage of unittest2

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/test-refactor@13412 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Paul McMillan 2010-07-02 17:19:17 +00:00
parent e87ead6d08
commit 62e587418c

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.test import TestCase from django.test import TestCase
from django.utils.unittest import skipIf
from django.conf import settings from django.conf import settings
from django.db import transaction, IntegrityError, DEFAULT_DB_ALIAS from django.db import transaction, IntegrityError, DEFAULT_DB_ALIAS
@ -116,10 +116,10 @@ class CustomPkTestCase(TestCase):
# SQLite lets objects be saved with an empty primary key, even though an # SQLite lets objects be saved with an empty primary key, even though an
# integer is expected. So we can't check for an error being raised in that case # integer is expected. So we can't check for an error being raised in that case
# for SQLite. Remove it from the suite for this next bit. # for SQLite. Remove it from the suite for this next bit.
@skipIf(settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] == 'django.db.backends.sqlite3',
"SQLite lets objects be saved with empty pk")
def test_empty_pk_error(self): def test_empty_pk_error(self):
#fixme, improve this skiping with unittest2 self.assertRaises(IntegrityError,
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] != 'django.db.backends.sqlite3': Employee.objects.create,
self.assertRaises(IntegrityError, first_name='Tom', last_name='Smith')
Employee.objects.create,
first_name='Tom', last_name='Smith')