Skip to content

Commit

Permalink
Convert unittest class base tests to pytest function tests (#553)
Browse files Browse the repository at this point in the history
Co-authored-by: Vasyl Dizhak <[email protected]>
Co-authored-by: Terence D. Honles <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2021
1 parent 6ff7c54 commit 5bf67ab
Show file tree
Hide file tree
Showing 10 changed files with 1,186 additions and 1,123 deletions.
1 change: 1 addition & 0 deletions changelog.d/553.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert most unittest class tests to pytest tests.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package = "django_redis"
type = [
{ name = "Features", directory = "feature", showcontent = true },
{ name = "Bug Fixes", directory = "bugfix", showcontent = true },
{ name = "Miscellaneous", directory = "misc", showcontent = true },
{ name = "Documentation", directory = "doc", showcontent = true },
{ name = "Deprecations and Removals", directory = "removal", showcontent = true },
]
7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ deps =
pytest-cov
pytest-django
pytest-pythonpath
pytest-mock
redismaster: https://github.com/andymccurdy/redis-py/archive/master.tar.gz
lz4>=0.15
pyzstd>=0.15
Expand All @@ -130,14 +131,18 @@ commands =
black: black --target-version py36 {posargs:--check --diff} setup.py django_redis/ tests/
flake8: flake8 {posargs} setup.py django_redis/ tests/
isort: isort {posargs:--check-only --diff} django_redis/ tests/
mypy: mypy {posargs:--cobertura-xml-report .} django_redis
mypy: mypy {posargs:--cobertura-xml-report .} django_redis tests
deps =
black
django-stubs
flake8
isort >= 5.0.2
lxml
mypy
# typing dependencies
pytest
pytest-django
pytest-mock
types-redis
skip_install = true

Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing import Iterable

import pytest
from django.core.cache import cache as default_cache

from django_redis.cache import RedisCache


@pytest.fixture
def cache() -> Iterable[RedisCache]:
yield default_cache
default_cache.clear()
12 changes: 11 additions & 1 deletion tests/settings/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
},
}

INSTALLED_APPS = ["django.contrib.sessions"]
# Include `django.contrib.auth` and `django.contrib.contenttypes` for mypy /
# django-stubs.

# See:
# - https://github.com/typeddjango/django-stubs/issues/318
# - https://github.com/typeddjango/django-stubs/issues/534
INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
]

USE_TZ = False
Loading

0 comments on commit 5bf67ab

Please sign in to comment.