From a81ad18095573cef0cea625a59157268d8d6e79b Mon Sep 17 00:00:00 2001 From: Micah Denbraver Date: Wed, 1 Apr 2015 13:19:12 -0700 Subject: [PATCH] Resync db after registering new models --- simple_history/tests/tests/test_models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/simple_history/tests/tests/test_models.py b/simple_history/tests/tests/test_models.py index f0667d929..c6072eb8f 100644 --- a/simple_history/tests/tests/test_models.py +++ b/simple_history/tests/tests/test_models.py @@ -6,6 +6,7 @@ except ImportError: from unittest2 import skipUnless +from six.moves import cStringIO as StringIO import django try: from django.contrib.auth import get_user_model @@ -17,6 +18,7 @@ from django.db.models.fields.proxy import OrderWrt from django.test import TestCase from django.core.files.base import ContentFile +from django.core import management from simple_history.models import HistoricalRecords, convert_auto_field from simple_history import register @@ -326,6 +328,9 @@ def test_register_custome_records(self): class CreateHistoryModelTests(TestCase): + def tearDown(self): + management.call_command('syncdb', interactive=False, stdout=StringIO(), stderr=StringIO()) + def test_create_history_model_with_one_to_one_field_to_integer_field(self): records = HistoricalRecords() records.module = AdminProfile.__module__ @@ -340,7 +345,7 @@ def test_create_history_model_with_one_to_one_field_to_char_field(self): records.module = Bookcase.__module__ try: records.create_history_model(Bookcase) - except: + except Exception: self.fail("SimpleHistory should handle foreign keys to one to one" "fields to char fields without throwing an exception.") @@ -349,7 +354,7 @@ def test_create_history_model_with_multiple_one_to_ones(self): records.module = MultiOneToOne.__module__ try: records.create_history_model(MultiOneToOne) - except: + except Exception: self.fail("SimpleHistory should handle foreign keys to one to one" "fields to one to one fields without throwing an " "exception.")