diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac45f43c..10257a6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - run: pip install Django~="${{ matrix.django-version }}.0" - - run: python setup.py test + - run: python -m pip install .[test] + - run: python -m pip install Django~="${{ matrix.django-version }}.0" + - run: python -m pytest - uses: codecov/codecov-action@v3 diff --git a/setup.cfg b/setup.cfg index dac80ca6..949f93bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,10 +42,9 @@ install_requires = django>=2.2 setup_requires = setuptools_scm - sphinx - pytest-runner -tests_require = - mock + +[options.extras_require] +test = pytest pytest-cov pytest-django @@ -70,8 +69,6 @@ addopts = --tb=short -rxs --cov=health_check - --cov-report=term - --cov-report=xml [flake8] max-line-length = 88 diff --git a/tests/test_cache.py b/tests/test_cache.py index 15e983b9..1d311377 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -1,6 +1,7 @@ +from unittest.mock import patch + from django.core.cache.backends.base import BaseCache, CacheKeyWarning from django.test import TestCase -from mock import patch from health_check.cache.backends import CacheBackend diff --git a/tests/test_celery_ping.py b/tests/test_celery_ping.py index efb3a8ce..a03dd0b7 100644 --- a/tests/test_celery_ping.py +++ b/tests/test_celery_ping.py @@ -1,7 +1,8 @@ +from unittest.mock import patch + import pytest from django.apps import apps from django.conf import settings -from mock import patch from health_check.contrib.celery_ping.apps import HealthCheckConfig from health_check.contrib.celery_ping.backends import CeleryPingHealthCheck @@ -19,7 +20,7 @@ class TestCeleryPingHealthCheck: def health_check(self): return CeleryPingHealthCheck() - def test_check_status_doesnt_add_errors_when_ping_successfull(self, health_check): + def test_check_status_doesnt_add_errors_when_ping_successful(self, health_check): celery_worker = "celery@4cc150a7b49b" with patch( diff --git a/tests/test_commands.py b/tests/test_commands.py index 0a18a322..59c0ceb2 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -18,7 +18,7 @@ def check_status(self): class TestCommand: - @pytest.yield_fixture(autouse=True) + @pytest.fixture(autouse=True) def setup(self): plugin_dir.reset() plugin_dir.register(FailPlugin) diff --git a/tests/test_db.py b/tests/test_db.py index 13415d29..fb3c4917 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -1,7 +1,8 @@ +from unittest.mock import patch + from django.db import DatabaseError, IntegrityError from django.db.models import Model from django.test import TestCase -from mock import patch from health_check.db.backends import DatabaseBackend diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 6cf0f175..e4678e49 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -1,6 +1,7 @@ +from unittest.mock import patch + from django.db.migrations import Migration from django.test import TestCase -from mock import patch from health_check.contrib.migrations.backends import MigrationsHealthCheck diff --git a/tests/test_mixins.py b/tests/test_mixins.py index 2b9b4c09..1a35e936 100644 --- a/tests/test_mixins.py +++ b/tests/test_mixins.py @@ -20,7 +20,7 @@ class Checker(CheckMixin): class TestCheckMixin: - @pytest.yield_fixture(autouse=True) + @pytest.fixture(autouse=True) def setup(self): plugin_dir.reset() plugin_dir.register(FailPlugin) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 6329c7ad..879d4b9d 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -15,7 +15,7 @@ def check_status(self): class TestPlugin: - @pytest.yield_fixture(autouse=True) + @pytest.fixture(autouse=True) def setup(self): plugin_dir.reset() plugin_dir.register(FakePlugin) diff --git a/tests/test_rabbitmq.py b/tests/test_rabbitmq.py index 76b08fa1..516985ad 100644 --- a/tests/test_rabbitmq.py +++ b/tests/test_rabbitmq.py @@ -1,4 +1,5 @@ -import mock +from unittest import mock + from amqp.exceptions import AccessRefused from health_check.contrib.rabbitmq.backends import RabbitMQHealthCheck diff --git a/tests/test_redis.py b/tests/test_redis.py index 4796feef..c17720d4 100644 --- a/tests/test_redis.py +++ b/tests/test_redis.py @@ -1,4 +1,5 @@ -import mock +from unittest import mock + from redis.exceptions import ConnectionError, TimeoutError from health_check.contrib.redis.backends import RedisHealthCheck diff --git a/tests/test_storage.py b/tests/test_storage.py index 5a2442e8..f8eb90b3 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -1,4 +1,5 @@ -import mock +from unittest import mock + from django.core.files.storage import Storage from django.test import TestCase diff --git a/tests/testapp/settings.py b/tests/testapp/settings.py index f094e2d1..620e7190 100644 --- a/tests/testapp/settings.py +++ b/tests/testapp/settings.py @@ -58,7 +58,7 @@ SECRET_KEY = uuid.uuid4().hex -USE_L10N = True +USE_TZ = True CELERY_QUEUES = [ Queue("default"),