From 8352b10b17304ba5095e0dd2f269b5cc1c6e3b19 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Wed, 15 May 2019 18:38:39 +0200 Subject: [PATCH] made tests compatible with newer django releases --- example/db_router.py | 8 ++++---- example/tests.py | 2 ++ tox.ini | 15 ++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/example/db_router.py b/example/db_router.py index 6ccf1f4..5bf1b58 100644 --- a/example/db_router.py +++ b/example/db_router.py @@ -1,4 +1,3 @@ - class Router(object): TABLE_MAPPINGS = { 'autocompletionexample_extraspam': 'other', @@ -11,16 +10,17 @@ def get_db(self, model, **hints): db_for_read = db_for_write = get_db def allow_migrate(self, *args, **hints): - # Django 1.8, 1.9 and 1.10 all have different behaviour... sigh + # Django 1.8, 1.9, 1.10 and 2.2 all have different behaviour... sigh if 'model_name' in hints: model_name = hints['model_name'] elif 'model' in hints: model_name = hints['model']._meta.db_table - else: + elif hasattr(args[1], '_meta'): model_name = args[1]._meta.db_table + else: + model_name = args[1] return self.TABLE_MAPPINGS.get(model_name, 'default') def allow_relation(self, obj1, obj2, **hints): return True - diff --git a/example/tests.py b/example/tests.py index efc11a5..00ee276 100644 --- a/example/tests.py +++ b/example/tests.py @@ -33,6 +33,8 @@ class Form(forms.Form): class BaseTestCase(test.TestCase): + databases = ['default', 'other'] + @transaction.atomic def setUp(self): self.client = client.Client() diff --git a/tox.ini b/tox.ini index b50fca8..049da02 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,10 @@ [tox] envlist = py{py,27}-django11, - py35-django{11,20}, - py36-django{11,20}, + py35-django{11,21,22}, + py36-django{11,21,22}, + py37-django{11,21,22}, + py38-django{11,21,22}, flake8, docs @@ -12,13 +14,16 @@ usedevelop = True [testenv] deps = django11: Django<2.0 - django20: Django>=2.0,<2.1 + django21: Django>=2.1,<2.2 + django22: Django>=2.2,<2.3 -r{toxinidir}/example/requirements.txt envlist = py{py,27}-django11, - py35-django{11,20}, - py36-django{11,20}, + py35-django{11,21,22}, + py36-django{11,21,22}, + py37-django{11,21,22}, + py38-django{11,21,22} commands = python setup.py test