diff --git a/tests/get_or_create/tests.py b/tests/get_or_create/tests.py
index e9cce9b..3f70626 100644
a
|
b
|
from __future__ import absolute_import
|
3 | 3 | from datetime import date |
4 | 4 | import traceback |
5 | 5 | |
6 | | from django.db import IntegrityError |
| 6 | from django.db import IntegrityError, DataError, connection |
7 | 7 | from django.test import TestCase, TransactionTestCase |
| 8 | from django.utils.unittest.case import skipUnless |
8 | 9 | |
9 | 10 | from .models import Person, ManualPrimaryKeyTest, Profile |
10 | 11 | |
… |
… |
class GetOrCreateTests(TestCase):
|
64 | 65 | formatted_traceback = traceback.format_exc() |
65 | 66 | self.assertIn('obj.save', formatted_traceback) |
66 | 67 | |
| 68 | @skipUnless(connection.vendor == 'postgresql', "This test only applies to PostgreSQL") |
| 69 | def test_savepoint_rollback(self): |
| 70 | # Provoke a DataError in .get_or_create() |
| 71 | try: |
| 72 | Person.objects.get_or_create(birthday=date(1970, 1, 1), defaults={ |
| 73 | 'first_name': "\xff", |
| 74 | 'last_name': "\xff" |
| 75 | }) |
| 76 | except DataError: |
| 77 | pass |
| 78 | # Create another object to make sure the database is not in a "broken" state |
| 79 | Person.objects.create(first_name="Bob", last_name="Ross", birthday=date(1950, 1, 1)) |
| 80 | |
67 | 81 | |
68 | 82 | class GetOrCreateTransactionTests(TransactionTestCase): |
69 | 83 | |