diff --git a/.gitignore b/.gitignore index bab3b71..c18fed3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ dist/ docs/_build/ htmlcov/ venv/ +.venv/ diff --git a/polymorphic/tests/migrations/0001_initial.py b/polymorphic/tests/migrations/0001_initial.py index 4707a36..38106a3 100644 --- a/polymorphic/tests/migrations/0001_initial.py +++ b/polymorphic/tests/migrations/0001_initial.py @@ -1450,6 +1450,13 @@ class Migration(migrations.Migration): to="tests.ParentModelWithManager", ), ), + migrations.AddField( + model_name="childmodelwithmanager", + name="field1", + field=models.CharField( + max_length=10, + ), + ), migrations.AddField( model_name="childmodelwithmanager", name="polymorphic_ctype", diff --git a/polymorphic/tests/models.py b/polymorphic/tests/models.py index 96e361f..494b98f 100644 --- a/polymorphic/tests/models.py +++ b/polymorphic/tests/models.py @@ -222,6 +222,7 @@ class ParentModelWithManager(PolymorphicModel): class ChildModelWithManager(PolymorphicModel): # Also test whether foreign keys receive the manager: + field1 = models.CharField(max_length=10) # needed as MyManager uses it fk = models.ForeignKey( ParentModelWithManager, on_delete=models.CASCADE, related_name="childmodel_set" ) diff --git a/polymorphic/tests/test_multidb.py b/polymorphic/tests/test_multidb.py index b70a8d5..dee08d4 100644 --- a/polymorphic/tests/test_multidb.py +++ b/polymorphic/tests/test_multidb.py @@ -18,7 +18,7 @@ from polymorphic.tests.models import ( class MultipleDatabasesTests(TestCase): - multi_db = True + databases = ["default", "secondary"] def test_save_to_non_default_database(self): Model2A.objects.db_manager("secondary").create(field1="A1") diff --git a/polymorphic/tests/test_orm.py b/polymorphic/tests/test_orm.py index a0fd1e8..84da2a5 100644 --- a/polymorphic/tests/test_orm.py +++ b/polymorphic/tests/test_orm.py @@ -481,21 +481,22 @@ class PolymorphicTests(TransactionTestCase): def test_foreignkey_field(self): self.create_model2abcd() - object2a = Model2A.base_objects.get(field1="C1") + object2a = Model2A.objects.get(field1="C1") self.assertEqual(object2a.model2b.__class__, Model2B) - object2b = Model2B.base_objects.get(field1="C1") + object2b = Model2B.objects.get(field1="C1") self.assertEqual(object2b.model2c.__class__, Model2C) def test_onetoone_field(self): self.create_model2abcd() + # FIXME: We should not use base_objects here. a = Model2A.base_objects.get(field1="C1") b = One2OneRelatingModelDerived.objects.create( one2one=a, field1="f1", field2="f2" ) - # this result is basically wrong, probably due to Django cacheing (we used base_objects), but should not be a problem + # FIXME: this result is basically wrong, probably due to Django cacheing (we used base_objects), but should not be a problem self.assertEqual(b.one2one.__class__, Model2A) self.assertEqual(b.one2one_id, b.one2one.id) @@ -808,7 +809,6 @@ class PolymorphicTests(TransactionTestCase): self.assertIs(type(ModelWithMyManager.objects), MyManager) self.assertIs(type(ModelWithMyManager._default_manager), MyManager) - self.assertIs(type(ModelWithMyManager.base_objects), models.Manager) def test_user_defined_manager_as_secondary(self): self.create_model2abcd() @@ -831,7 +831,6 @@ class PolymorphicTests(TransactionTestCase): self.assertIs( type(ModelWithMyManagerNoDefault._default_manager), PolymorphicManager ) - self.assertIs(type(ModelWithMyManagerNoDefault.base_objects), models.Manager) def test_user_objects_manager_as_secondary(self): self.create_model2abcd() @@ -841,7 +840,6 @@ class PolymorphicTests(TransactionTestCase): self.assertIs(type(ModelWithMyManagerDefault.my_objects), MyManager) self.assertIs(type(ModelWithMyManagerDefault.objects), PolymorphicManager) self.assertIs(type(ModelWithMyManagerDefault._default_manager), MyManager) - self.assertIs(type(ModelWithMyManagerDefault.base_objects), models.Manager) def test_user_defined_queryset_as_manager(self): self.create_model2abcd() @@ -864,7 +862,6 @@ class PolymorphicTests(TransactionTestCase): type(ModelWithMyManager2._default_manager).__name__, "PolymorphicManagerFromMyManagerQuerySet", ) - self.assertIs(type(ModelWithMyManager2.base_objects), models.Manager) def test_manager_inheritance(self): # by choice of MRO, should be MyManager from MROBase1. diff --git a/tox.ini b/tox.ini index e507416..2e4d2c3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] envlist = - py35-django{21,22,master} - py36-django{21,22,30,31,master} - py37-django{21,22,30,31,master} - py38-django{21,22,30,31,master} + py35-django{21,22} + py36-django{21,22,30,31} + py37-django{21,22,30,31} + py38-django{21,22,30,31} docs [testenv] @@ -12,6 +12,7 @@ setenv = postgres: DEFAULT_DATABASE = postgres:///default postgres: SECONDARY_DATABASE = postgres:///secondary deps = + ipdb coverage dj-database-url django21: Django ~= 2.1