diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57a2078..e36524b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,43 +12,26 @@ jobs: fail-fast: false matrix: versions: - - python: 3.5 - toxenv: py35-2.2.X - - python: 3.6 - toxenv: py36-2.2.X - - python: 3.7 - toxenv: py37-2.2.X - python: 3.8 - toxenv: py38-2.2.X - - python: 3.9 - toxenv: py39-2.2.X - - - python: 3.6 - toxenv: py36-3.0.X - - python: 3.7 - toxenv: py37-3.0.X + toxenv: py38-3.2.X - python: 3.8 - toxenv: py38-3.0.X - - python: 3.9 - toxenv: py39-3.0.X - - - python: 3.6 - toxenv: py36-3.1.X - - python: 3.7 - toxenv: py37-3.1.X + toxenv: py38-4.0.X - python: 3.8 - toxenv: py38-3.1.X - - python: 3.9 - toxenv: py39-3.1.X - - - python: 3.6 - toxenv: py36-3.2.X - - python: 3.7 - toxenv: py37-3.2.X - - python: 3.8 - toxenv: py38-3.2.X + toxenv: py38-4.2.X + - python: 3.9 toxenv: py39-3.2.X + - python: 3.9 + toxenv: py39-4.0.X + - python: 3.9 + toxenv: py39-4.2.X + + - python: "3.10" + toxenv: py310-3.2.X + - python: "3.10" + toxenv: py310-4.0.X + - python: "3.10" + toxenv: py310-4.2.X runs-on: ubuntu-latest steps: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7de3f76..0000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -dist: xenial - -sudo: false - -language: python - -matrix: - include: - - python: 3.5 - env: TOX_ENV=ppy35-2.2.X - - - python: 3.6 - env: TOX_ENV=ppy36-2.2.X - - - python: 3.7 - env: TOX_ENV=ppy37-2.2.X - - - python: 3.8 - env: TOX_ENV=ppy38-2.2.X - - - python: 3.9 - env: TOX_ENV=ppy39-2.2.X - - - python: 3.6 - env: TOX_ENV=ppy36-3.0.X - - - python: 3.7 - env: TOX_ENV=ppy37-3.0.X - - - python: 3.8 - env: TOX_ENV=ppy38-3.0.X - - - python: 3.9 - env: TOX_ENV=ppy39-3.0.X - - - python: 3.6 - env: TOX_ENV=ppy36-3.1.X - - - python: 3.7 - env: TOX_ENV=ppy37-3.1.X - - - python: 3.8 - env: TOX_ENV=ppy38-3.1.X - - - python: 3.9 - env: TOX_ENV=ppy39-3.1.X - - - python: 3.6 - env: TOX_ENV=ppy36-3.2.X - - - python: 3.7 - env: TOX_ENV=ppy37-3.2.X - - - python: 3.8 - env: TOX_ENV=ppy38-3.2.X - - - python: 3.9 - env: TOX_ENV=ppy39-3.2.X - -install: - - pip install tox - -script: - - tox -e $TOX_ENV diff --git a/multidb/__init__.py b/multidb/__init__.py index 9541e80..5ac3bdd 100644 --- a/multidb/__init__.py +++ b/multidb/__init__.py @@ -139,8 +139,8 @@ class PinningReplicaRouter(ReplicaRouter): """ def db_for_read(self, model, **hints): - """Send reads to replicas in round-robin unless this thread is "stuck" to - the master.""" + """Send reads to replicas in round-robin unless this thread is + "stuck" to the master.""" return DEFAULT_DB_ALIAS if this_thread_is_pinned() else get_replica() diff --git a/multidb/tests.py b/multidb/tests.py index 125cff4..843d503 100644 --- a/multidb/tests.py +++ b/multidb/tests.py @@ -124,9 +124,13 @@ class MiddlewareTests(UnpinningTestCase): def setUp(self): super(MiddlewareTests, self).setUp() + # Django 4.0 requires response as an arg + # https://stackoverflow.com/questions/62944755/how-to-unittest-new-style-django-middleware + get_response = mock.MagicMock() + # Every test uses these, so they're okay as attrs. self.request = HttpRequest() - self.middleware = PinningRouterMiddleware() + self.middleware = PinningRouterMiddleware(get_response) def test_pin_on_cookie(self): """Thread should pin when the cookie is set.""" diff --git a/requirements.txt b/requirements.txt index 913c391..d507e8c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -django-nose==1.4.4 -flake8==3.3.0 +django-nose==1.4.7 +flake8==6.0.0 diff --git a/run.sh b/run.sh index 395b4c0..1c42fa9 100755 --- a/run.sh +++ b/run.sh @@ -13,9 +13,9 @@ usage() { case "$1" in "test" ) - django-admin.py test multidb ;; + django-admin test multidb ;; "shell" ) - django-admin.py shell ;; + django-admin shell ;; "check" ) flake8 multidb ;; * ) diff --git a/test_settings.py b/test_settings.py index 57f3ab2..caa8dc0 100644 --- a/test_settings.py +++ b/test_settings.py @@ -1,7 +1,7 @@ # A Django settings module to support the tests SECRET_KEY = 'dummy' -TEST_RUNNER = 'django_nose.runner.NoseTestSuiteRunner' +# TEST_RUNNER = 'django_nose.runner.NoseTestSuiteRunner' MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', diff --git a/tox.ini b/tox.ini index 8fef433..6ffdd31 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,29 @@ [tox] envlist = flake8 - {py35,py36,py37,py38,py39}-2.2.X - {py36,py37,py38,py39}-3.0.X - {py36,py37,py38,py39}-3.1.X - {py36,py37,py38,py39}-3.2.X + {py38,py39,py310}-3.2.X + {py38,py39,py310}-4.0.X + {py38,py39,py310}-4.1.X + {py38,py39,py310}-4.2.X [testenv] +allowlist_externals=./run.sh basepython = - py35: python3.5 - py36: python3.6 - py37: python3.7 py38: python3.8 py39: python3.9 + py10: python3.10 commands = ./run.sh test python --version - django-admin.py --version + django-admin --version pip freeze deps = - 2.2.X: Django>=2.2,<2.3 - 3.0.X: Django>=3.0,<3.1 - 3.1.X: Django>=3.1,<3.2 3.2.X: Django>=3.2,<4.0 + 4.0.X: Django>=4.0,<4.1 + 4.1.X: Django>=4.1,<4.2 + 4.2.X: Django>=4.2,<5.0 -r{toxinidir}/requirements.txt [testenv:flake8]