Skip to content

Commit

Permalink
テスト実行をpytestに移行
Browse files Browse the repository at this point in the history
  • Loading branch information
kashewnuts committed Feb 6, 2024
1 parent bee2123 commit 438e693
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 70 deletions.
7 changes: 0 additions & 7 deletions beproud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = locals()['__path__'] # make PyFlakes happy
__path__ = extend_path(__path__, __name__)
7 changes: 0 additions & 7 deletions beproud/django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = locals()['__path__'] # make PyFlakes happy
__path__ = extend_path(__path__, __name__)
4 changes: 0 additions & 4 deletions beproud/django/notify/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from beproud.django.notify.tests.test_basic import * #NOQA
from beproud.django.notify.tests.test_mail import * #NOQA
from beproud.django.notify.tests.test_storage import * #NOQA
from beproud.django.notify.tests.test_tasks import * #NOQA
8 changes: 6 additions & 2 deletions test_settings.py → beproud/django/notify/tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Django3では、標準のdjango.conf.global_settingsの定数をオーバーライドすると例外が発生する場合がある。
# https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188
# そのため、testではdjango.conf.global_settingsを直接利用せず、このtest用settings定数を使用する。
import os
import celery

SECRET_KEY = "SECRET"
INSTALLED_APPS = (
Expand All @@ -22,7 +24,6 @@
}
}

import os
BASE_PATH = os.path.dirname(__file__)

TEMPLATES = [
Expand Down Expand Up @@ -56,5 +57,8 @@
BPNOTIFY_SETTINGS_STORAGE = 'beproud.django.notify.storage.db.DBStorage'

# The name of the class to use to run the test suite
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
# TEST_RUNNER = 'django.test.runner.DiscoverRunner'

app = celery.Celery()
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks(lambda: INSTALLED_APPS)
3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

46 changes: 0 additions & 46 deletions tests.py

This file was deleted.

8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
envlist = py{39,310,311}-dj{32,42}-celery{52,53},py312-dj42-celery53
skipsdist = True

[pytest]
python_paths = .
python_files = tests test_*.py *_tests.py
django_find_project = false
DJANGO_SETTINGS_MODULE = beproud.django.notify.tests.settings

[testenv]
basepython =
py39: python3.9
Expand All @@ -19,7 +25,7 @@ deps =
dj42: Django>=4.2,<5.0
celery52: celery>=5.2,<5.3
celery53: celery>=5.3,<5.4
commands=python setup.py test
commands=pytest {posargs}

# tox-gh-actionsパッケージの設定
[gh-actions]
Expand Down

0 comments on commit 438e693

Please sign in to comment.