Skip to content

Commit 5bf67ab

Browse files
rootartdizhakbotterencehonles
authored
Convert unittest class base tests to pytest function tests (#553)
Co-authored-by: Vasyl Dizhak <[email protected]> Co-authored-by: Terence D. Honles <[email protected]>
1 parent 6ff7c54 commit 5bf67ab

File tree

10 files changed

+1186
-1123
lines changed

10 files changed

+1186
-1123
lines changed

changelog.d/553.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert most unittest class tests to pytest tests.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package = "django_redis"
77
type = [
88
{ name = "Features", directory = "feature", showcontent = true },
99
{ name = "Bug Fixes", directory = "bugfix", showcontent = true },
10+
{ name = "Miscellaneous", directory = "misc", showcontent = true },
1011
{ name = "Documentation", directory = "doc", showcontent = true },
1112
{ name = "Deprecations and Removals", directory = "removal", showcontent = true },
1213
]

setup.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ deps =
119119
pytest-cov
120120
pytest-django
121121
pytest-pythonpath
122+
pytest-mock
122123
redismaster: https://github.com/andymccurdy/redis-py/archive/master.tar.gz
123124
lz4>=0.15
124125
pyzstd>=0.15
@@ -130,14 +131,18 @@ commands =
130131
black: black --target-version py36 {posargs:--check --diff} setup.py django_redis/ tests/
131132
flake8: flake8 {posargs} setup.py django_redis/ tests/
132133
isort: isort {posargs:--check-only --diff} django_redis/ tests/
133-
mypy: mypy {posargs:--cobertura-xml-report .} django_redis
134+
mypy: mypy {posargs:--cobertura-xml-report .} django_redis tests
134135
deps =
135136
black
136137
django-stubs
137138
flake8
138139
isort >= 5.0.2
139140
lxml
140141
mypy
142+
# typing dependencies
143+
pytest
144+
pytest-django
145+
pytest-mock
141146
types-redis
142147
skip_install = true
143148

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import Iterable
2+
3+
import pytest
4+
from django.core.cache import cache as default_cache
5+
6+
from django_redis.cache import RedisCache
7+
8+
9+
@pytest.fixture
10+
def cache() -> Iterable[RedisCache]:
11+
yield default_cache
12+
default_cache.clear()

tests/settings/sqlite.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
},
2424
}
2525

26-
INSTALLED_APPS = ["django.contrib.sessions"]
26+
# Include `django.contrib.auth` and `django.contrib.contenttypes` for mypy /
27+
# django-stubs.
28+
29+
# See:
30+
# - https://github.com/typeddjango/django-stubs/issues/318
31+
# - https://github.com/typeddjango/django-stubs/issues/534
32+
INSTALLED_APPS = [
33+
"django.contrib.auth",
34+
"django.contrib.contenttypes",
35+
"django.contrib.sessions",
36+
]
2737

2838
USE_TZ = False

0 commit comments

Comments
 (0)