From ef76168b42e4c25138272689e4f417c1be10716d Mon Sep 17 00:00:00 2001 From: kashewnuts Date: Thu, 1 Feb 2024 17:57:03 +0900 Subject: [PATCH 1/5] support Python3.10 over & Django4.2 --- .github/workflows/tests.yml | 8 +- .hgignore | 19 -- CHANGES.rst | 12 ++ MANIFEST.in | 1 - README.rst | 7 +- beproud/django/notify/models.py | 6 +- beproud/django/notify/tests/__init__.py | 4 - .../django/notify/tests/settings.py | 9 +- beproud/django/notify/tests/test_basic.py | 176 +++++++++--------- beproud/django/notify/tests/test_mail.py | 16 +- beproud/django/notify/tests/test_tasks.py | 10 +- setup.py | 13 +- tests.py | 46 ----- tox.ini | 35 ++-- 14 files changed, 158 insertions(+), 204 deletions(-) delete mode 100644 .hgignore rename test_settings.py => beproud/django/notify/tests/settings.py (90%) delete mode 100644 tests.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ae22dd..4f6c9c4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,16 +14,16 @@ jobs: # 並列して実行する各ジョブのPythonバージョン strategy: matrix: - python-version: ['3.6', '3.9'] - django-version: ['2.2', '3.2'] + python-version: ['3.9', '3.10', '3.11', '3.12'] + django-version: ['3.2', '4.2'] steps: # ソースコードをチェックアウト - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # ジョブのPython環境を設定 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/.hgignore b/.hgignore deleted file mode 100644 index a808144..0000000 --- a/.hgignore +++ /dev/null @@ -1,19 +0,0 @@ -syntax: glob -*.orig -*.rej -*~ -*.bak -*.marks -*.o -*.pyc -*.swp -*.egg-info -*.egg -.tox -build -dist -pip-log.txt -docs/*/build - -syntax: regexp -.*\#.*\#$ diff --git a/CHANGES.rst b/CHANGES.rst index 3a19a67..e0e1606 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,18 @@ ChangeLog ========= +0.49 (2024-02-XX) +=================== + +Features: + +* Add Support Python3.10~3.12, Django4.2 + +Incompatible Changes: + +* Drop Python3.6 & Django2.2 +* Migrate from django-jsonfield to models.JSONField + 0.48 (2022-04-11) =================== diff --git a/MANIFEST.in b/MANIFEST.in index 4a467e1..3c683ad 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ -recursive-include beproud/django/notify/tests/templates * recursive-include beproud/django/notify/templates * recursive-include beproud/django/notify/fixtures * include README.rst diff --git a/README.rst b/README.rst index 5a8adc5..8e43d6f 100644 --- a/README.rst +++ b/README.rst @@ -7,11 +7,10 @@ Requirements ============ -* Python (3.6, 3.9) -* Celery (4.2, 5.1, 5.2) -* Django (2.2, 3.2) +* Python (3.9, 3.10, 3.11, 3.12) +* Celery (5.2, 5.3) +* Django (3.2, 4.2) * six -* django-jsonfield (1.0.1) Links ================= diff --git a/beproud/django/notify/models.py b/beproud/django/notify/models.py index 9e3b6ab..313c147 100644 --- a/beproud/django/notify/models.py +++ b/beproud/django/notify/models.py @@ -3,11 +3,9 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.db import models -import jsonfield - from beproud.django.notify.api import _get_media_map __all__ = ( @@ -42,7 +40,7 @@ class Notification(models.Model): notify_type = models.CharField(_('notify type'), max_length=100, db_index=True) media = models.CharField(_('media'), max_length=100, choices=MediaChoices(), db_index=True) - extra_data = jsonfield.JSONField(_('extra data'), null=True, blank=True) + extra_data = models.JSONField(_('extra data'), null=True, blank=True) ctime = models.DateTimeField(_('created'), auto_now_add=True, db_index=True) diff --git a/beproud/django/notify/tests/__init__.py b/beproud/django/notify/tests/__init__.py index 49ba9c0..e69de29 100644 --- a/beproud/django/notify/tests/__init__.py +++ b/beproud/django/notify/tests/__init__.py @@ -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 diff --git a/test_settings.py b/beproud/django/notify/tests/settings.py similarity index 90% rename from test_settings.py rename to beproud/django/notify/tests/settings.py index 240e1cd..7a1ebf6 100644 --- a/test_settings.py +++ b/beproud/django/notify/tests/settings.py @@ -2,6 +2,9 @@ # 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 = ( 'django.contrib.auth', @@ -22,7 +25,6 @@ } } -import os BASE_PATH = os.path.dirname(__file__) TEMPLATES = [ @@ -56,5 +58,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) diff --git a/beproud/django/notify/tests/test_basic.py b/beproud/django/notify/tests/test_basic.py index 28ec02e..3db2272 100644 --- a/beproud/django/notify/tests/test_basic.py +++ b/beproud/django/notify/tests/test_basic.py @@ -29,32 +29,32 @@ def test_sending_model(self): user = User.objects.get(pk=2) items_sent = notify_now(user, 'follow', extra_data={"followed": "eggs"}) # 1 news model - self.assertEquals(items_sent, 1) + self.assertEqual(items_sent, 1) news = Notification.objects.filter(media='news') - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'follow') - self.assertEquals(news[0].target, user) - self.assertEquals(news[0].extra_data.get('followed'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'follow') + self.assertEqual(news[0].target, user) + self.assertEqual(news[0].extra_data.get('followed'), 'eggs') private_messages = Notification.objects.exclude(media='news') - self.assertEquals(len(private_messages), 0) + self.assertEqual(len(private_messages), 0) def test_sending_model_null(self): items_sent = notify_now(None, 'follow', extra_data={"followed": "eggs"}) # 1 news model - self.assertEquals(items_sent, 1) + self.assertEqual(items_sent, 1) news = Notification.objects.filter(media='news') - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'follow') - self.assertEquals(news[0].target, None) - self.assertEquals(news[0].extra_data.get('followed'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'follow') + self.assertEqual(news[0].target, None) + self.assertEqual(news[0].extra_data.get('followed'), 'eggs') private_messages = Notification.objects.exclude(media='news') - self.assertEquals(len(private_messages), 0) + self.assertEqual(len(private_messages), 0) def test_sending_model_types(self): user = User.objects.get(pk=2) @@ -62,42 +62,42 @@ def test_sending_model_types(self): # 1 private_messages model # 1 private_messages mail # 1 news model - self.assertEquals(items_sent, 3) + self.assertEqual(items_sent, 3) private_messages = Notification.objects.filter(media='private_messages') - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].media, 'private_messages') - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, user) - self.assertEquals(private_messages[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].media, 'private_messages') + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, user) + self.assertEqual(private_messages[0].extra_data.get('spam'), 'eggs') news = Notification.objects.filter(media='news') - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'private_msg') - self.assertEquals(news[0].target, user) - self.assertEquals(news[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'private_msg') + self.assertEqual(news[0].target, user) + self.assertEqual(news[0].extra_data.get('spam'), 'eggs') def test_sending_model_types_null(self): items_sent = notify_now(None, 'private_msg', extra_data={"spam": "eggs"}) # 1 private_messages model # 0 private_messages mail (No mail to null target) # 1 news model - self.assertEquals(items_sent, 2) + self.assertEqual(items_sent, 2) private_messages = Notification.objects.filter(media='private_messages') - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].media, 'private_messages') - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, None) - self.assertEquals(private_messages[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].media, 'private_messages') + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, None) + self.assertEqual(private_messages[0].extra_data.get('spam'), 'eggs') news = Notification.objects.filter(media='news') - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'private_msg') - self.assertEquals(news[0].target, None) - self.assertEquals(news[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'private_msg') + self.assertEqual(news[0].target, None) + self.assertEqual(news[0].extra_data.get('spam'), 'eggs') def test_sending_model_multi(self): @@ -107,7 +107,7 @@ def test_sending_model_multi(self): # 3 private_messages model # 2 private_messages mail (No mail to null target) # 3 news model - self.assertEquals(items_sent, 8) + self.assertEqual(items_sent, 8) # User1 private_messages = Notification.objects.filter( @@ -115,22 +115,22 @@ def test_sending_model_multi(self): target_content_type=ContentType.objects.get_for_model(user[0]), target_object_id=user[0].id, ) - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].media, 'private_messages') - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, user[0]) - self.assertEquals(private_messages[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].media, 'private_messages') + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, user[0]) + self.assertEqual(private_messages[0].extra_data.get('spam'), 'eggs') news = Notification.objects.filter( media='news', target_content_type=ContentType.objects.get_for_model(user[0]), target_object_id=user[0].id, ) - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'private_msg') - self.assertEquals(news[0].target, user[0]) - self.assertEquals(news[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'private_msg') + self.assertEqual(news[0].target, user[0]) + self.assertEqual(news[0].extra_data.get('spam'), 'eggs') # User2 private_messages = Notification.objects.filter( @@ -138,22 +138,22 @@ def test_sending_model_multi(self): target_content_type=ContentType.objects.get_for_model(user[1]), target_object_id=user[1].id, ) - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].media, 'private_messages') - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, user[1]) - self.assertEquals(private_messages[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].media, 'private_messages') + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, user[1]) + self.assertEqual(private_messages[0].extra_data.get('spam'), 'eggs') news = Notification.objects.filter( media='news', target_content_type=ContentType.objects.get_for_model(user[1]), target_object_id=user[1].id, ) - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'private_msg') - self.assertEquals(news[0].target, user[1]) - self.assertEquals(news[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'private_msg') + self.assertEqual(news[0].target, user[1]) + self.assertEqual(news[0].extra_data.get('spam'), 'eggs') # Null Target private_messages = Notification.objects.filter( @@ -161,34 +161,34 @@ def test_sending_model_multi(self): target_content_type__isnull=True, target_object_id__isnull=True, ) - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].media, 'private_messages') - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, None) - self.assertEquals(private_messages[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].media, 'private_messages') + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, None) + self.assertEqual(private_messages[0].extra_data.get('spam'), 'eggs') news = Notification.objects.filter( media='news', target_content_type__isnull=True, target_object_id__isnull=True, ) - self.assertEquals(len(news), 1) - self.assertEquals(news[0].media, 'news') - self.assertEquals(news[0].notify_type, 'private_msg') - self.assertEquals(news[0].target, None) - self.assertEquals(news[0].extra_data.get('spam'), 'eggs') + self.assertEqual(len(news), 1) + self.assertEqual(news[0].media, 'news') + self.assertEqual(news[0].notify_type, 'private_msg') + self.assertEqual(news[0].target, None) + self.assertEqual(news[0].extra_data.get('spam'), 'eggs') def test_sending_with_settings(self): user = [User.objects.get(pk=1), User.objects.get(pk=2)] items_sent = notify_now(user, 'followed', extra_data={"spam": "eggs"}) - self.assertEquals(items_sent, 0) + self.assertEqual(items_sent, 0) self.assertTrue(set_notify_setting(user[0], 'followed', 'news', True)) items_sent = notify_now(user, 'followed', extra_data={"spam": "eggs"}) # 1 news model - self.assertEquals(items_sent, 1) + self.assertEqual(items_sent, 1) def test_settings_null(self): self.assertFalse(set_notify_setting(None, 'followed', 'news', True)) @@ -206,30 +206,30 @@ def test_get_notifications(self): # 2 private_messages model # 2 private_messages mail # 2 news model - self.assertEquals(items_sent, 6) + self.assertEqual(items_sent, 6) for index in [0, 1]: news = get_notifications(user[index], 'news') self.assertTrue(hasattr(news, '__iter__'), 'news notifications is not an iterable!') - self.assertEquals(len(news), 1) + self.assertEqual(len(news), 1) self.assertTrue(isinstance(news[0], dict), 'news notification is not a dict!') self.assertTrue(news[0].get('id', False), 'news notification has no id') - self.assertEquals(news[0].get('target'), user[index]) - self.assertEquals(news[0].get('notify_type'), 'private_msg') - self.assertEquals(news[0].get('media'), 'news') - self.assertEquals(news[0].get('extra_data'), {'spam': 'eggs'}) + self.assertEqual(news[0].get('target'), user[index]) + self.assertEqual(news[0].get('notify_type'), 'private_msg') + self.assertEqual(news[0].get('media'), 'news') + self.assertEqual(news[0].get('extra_data'), {'spam': 'eggs'}) self.assertTrue(isinstance(news[0].get('ctime'), datetime), 'news ctime is not a datetime!') private_messages = get_notifications(user[index], 'private_messages') self.assertTrue(hasattr(private_messages, '__iter__'), 'private_messages notifications is not an iterable!') - self.assertEquals(len(private_messages), 1) + self.assertEqual(len(private_messages), 1) self.assertTrue(isinstance(private_messages[0], dict), 'private_messages notification is not a dict!') self.assertTrue(private_messages[0].get('id', False), 'private_messages notification has no id') - self.assertEquals(private_messages[0].get('target'), user[index]) - self.assertEquals(private_messages[0].get('notify_type'), 'private_msg') - self.assertEquals(private_messages[0].get('media'), 'private_messages') - self.assertEquals(private_messages[0].get('extra_data'), {'spam': 'eggs'}) + self.assertEqual(private_messages[0].get('target'), user[index]) + self.assertEqual(private_messages[0].get('notify_type'), 'private_msg') + self.assertEqual(private_messages[0].get('media'), 'private_messages') + self.assertEqual(private_messages[0].get('extra_data'), {'spam': 'eggs'}) self.assertTrue(isinstance(news[0].get('ctime'), datetime), 'news ctime is not a datetime!') def test_object_list(self): @@ -274,9 +274,9 @@ def test_notify_type_length(self): user = User.objects.get(pk=2) items_sent = notify_now(user, 'notify_type_with_length_over_thirty') # 1 news model - self.assertEquals(items_sent, 1) + self.assertEqual(items_sent, 1) - self.assertEquals( + self.assertEqual( Notification.objects.filter(notify_type='notify_type_with_length_over_thirty').count(), 1, ) @@ -284,22 +284,22 @@ def test_notify_type_length(self): class ModelUnicodeTest(TestCase): def test_notification_unicode(self): notice = Notification() - self.assertEquals(str(notice), "None (, )") + self.assertEqual(str(notice), "None (, )") notice.notify_type = u"テスト" notice.media = "yyy" if six.PY2: - self.assertEquals(str(notice), u"None (テスト, yyy)".encode("utf-8")) + self.assertEqual(str(notice), u"None (テスト, yyy)".encode("utf-8")) else: - self.assertEquals(str(notice), "None (テスト, yyy)") + self.assertEqual(str(notice), "None (テスト, yyy)") def test_notification_setting_unicode(self): setting = NotifySetting() - self.assertEquals(str(setting), "None (, , no send)") + self.assertEqual(str(setting), "None (, , no send)") setting.notify_type = u"テスト" setting.media = "yyy" setting.send = True if six.PY2: - self.assertEquals(str(setting), u"None (テスト, yyy, send)".encode("utf-8")) + self.assertEqual(str(setting), u"None (テスト, yyy, send)".encode("utf-8")) else: - self.assertEquals(str(setting), "None (テスト, yyy, send)") + self.assertEqual(str(setting), "None (テスト, yyy, send)") diff --git a/beproud/django/notify/tests/test_mail.py b/beproud/django/notify/tests/test_mail.py index b215d30..c5e7abc 100644 --- a/beproud/django/notify/tests/test_mail.py +++ b/beproud/django/notify/tests/test_mail.py @@ -20,20 +20,20 @@ def test_sending_mail(self): # 1 private_messages model # 1 news model # 1 private_messages mail - self.assertEquals(items_sent, 3) + self.assertEqual(items_sent, 3) - self.assertEquals(len(mail.outbox), 1) - self.assertEquals(mail.outbox[0].subject, u'テストメール private_msg private_messages eggs') - self.assertEquals(mail.outbox[0].body, u'Text メールボディ private_msg private_messages eggs\n') + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].subject, u'テストメール private_msg private_messages eggs') + self.assertEqual(mail.outbox[0].body, u'Text メールボディ private_msg private_messages eggs\n') def test_from_email(self): user = User.objects.get(pk=2) notify_now(user, 'private_msg', extra_data={"spam": "eggs", "from_email": "spameggs@example.com"}) - self.assertEquals(len(mail.outbox), 1) - self.assertEquals(mail.outbox[0].from_email, "spameggs@example.com") + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].from_email, "spameggs@example.com") def test_from_mail(self): user = User.objects.get(pk=2) notify_now(user, 'private_msg', extra_data={"spam": "eggs", "from_mail": "spameggs@example.com"}) - self.assertEquals(len(mail.outbox), 1) - self.assertEquals(mail.outbox[0].from_email, "spameggs@example.com") + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].from_email, "spameggs@example.com") diff --git a/beproud/django/notify/tests/test_tasks.py b/beproud/django/notify/tests/test_tasks.py index a02834b..ccefd49 100644 --- a/beproud/django/notify/tests/test_tasks.py +++ b/beproud/django/notify/tests/test_tasks.py @@ -46,9 +46,9 @@ def test_notify_task(self): ) private_messages = Notification.objects.filter(media="news") - self.assertEquals(len(private_messages), 1) - self.assertEquals(private_messages[0].notify_type, 'private_msg') - self.assertEquals(private_messages[0].target, user) + self.assertEqual(len(private_messages), 1) + self.assertEqual(private_messages[0].notify_type, 'private_msg') + self.assertEqual(private_messages[0].target, user) @mock.patch.object(notify_tasks, 'notify_now') def test_notify_task_retry(self, notify_now): @@ -73,7 +73,7 @@ def _notify_now(*args, **kwargs): ) # First call + 2 retries = 3 calls - self.assertEquals(notify_now.call_count, 3) + self.assertEqual(notify_now.call_count, 3) @mock.patch.object(notify_tasks, 'notify_now') def test_notify_task_retry_fail(self, notify_now): @@ -98,4 +98,4 @@ def _notify_now(*args, **kwargs): ) # First call + 3 retries = 4 calls - self.assertEquals(notify_now.call_count, 4) + self.assertEqual(notify_now.call_count, 4) diff --git a/setup.py b/setup.py index 7bfab3c..02a4dc4 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def read_file(filename): long_description=read_file('README.rst'), long_description_content_type="text/x-rst", url='https://github.com/beproud/bpnotify/', - python_requires='>=3.6', + python_requires='>=3.9', classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Plugins', @@ -30,11 +30,13 @@ def read_file(filename): 'License :: OSI Approved :: BSD License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Framework :: Django', - 'Framework :: Django :: 2.2', 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.2', 'Topic :: Software Development :: Libraries :: Python Modules', ], include_package_data=True, @@ -42,9 +44,8 @@ def read_file(filename): namespace_packages=['beproud', 'beproud.django'], test_suite='tests.main', install_requires=[ - 'Django>=2.2', - 'django-jsonfield>=1.0.1', - 'Celery>=4.2', + 'Django~=3.2', + 'Celery~=5.2', 'six', ], zip_safe=False, diff --git a/tests.py b/tests.py deleted file mode 100644 index 8945737..0000000 --- a/tests.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import sys -import django -import celery - -import test_settings - -BASE_PATH = os.path.dirname(__file__) - - -def main(): - """ - Standalone django model test with a 'memory-only-django-installation'. - You can play with a django model without a complete django app installation. - http://www.djangosnippets.org/snippets/1044/ - """ - - # Django標準のdjango.conf.global_settingsを設定してしまうと、 - # Django3では、global_settingsの全ての定数を上書きする挙動になってしまい、 - # Django3の仕様で、多重上書き禁止エラーが検知され、例外が発生する。 - # (例) https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188 - # そのため、自前のテスト用settingsモジュール(test_settings.py)を設定する。 - os.environ["DJANGO_SETTINGS_MODULE"] = "test_settings" - - app = celery.Celery() - app.config_from_object('django.conf:settings', namespace='CELERY') - app.autodiscover_tasks(lambda: test_settings.INSTALLED_APPS) - - django.setup() - - from django.test.utils import get_runner - - # test用のsettings情報を用いて、Djangoのtest runnerクラスを取得 - TestRunner = get_runner(test_settings) - - # test runnerオブジェクトを生成 - test_runner = TestRunner() - - # test runnerにbpnotifyの単体テストのPathを渡して、bpnotifyの単体テストを実行する - failures = test_runner.run_tests(['beproud.django.notify.tests']) - - sys.exit(failures) - - -if __name__ == '__main__': - main() diff --git a/tox.ini b/tox.ini index 4512907..48ceb93 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,39 @@ # content of: tox.ini , put in same dir as setup.py [tox] -# celery5.2はPython3.7以降に対応しているため、Python3.6のテストではcelery 5.1までを使用する -envlist = py36-django{22,32}-celery{42,51},py39-django{22,32}-celery{51,52} +envlist = py{39,310,311}-dj{32,42}-celery{52,53},py312-dj42-celery53 +skipsdist = True + +[pytest] +python_files = tests test_*.py *_tests.py +django_find_project = false +DJANGO_SETTINGS_MODULE = beproud.django.notify.tests.settings [testenv] basepython = - py36: python3.6 py39: python3.9 - + py310: python3.10 + py311: python3.11 + py312: python3.12 deps = + pytest + pytest-django + pytest-pythonpath six - django22: Django~=2.2.12 - django32: Django~=3.2.1 - celery42: celery>=4.2,<4.3 - celery51: celery>=5.0,<5.2 + dj32: Django>=3.2,<4.0 + dj42: Django>=4.2,<5.0 celery52: celery>=5.2,<5.3 - -commands=python setup.py test + celery53: celery>=5.3,<5.4 +commands=pytest -Wa {posargs} # tox-gh-actionsパッケージの設定 [gh-actions] python = - 3.6: py36 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 [gh-actions:env] DJANGO = - 2.2: django22 - 3.2: django32 + 3.2: dj32 + 4.2: dj42 From 13f9dfef2d203c09d552ea57a592d6eaefb4e15a Mon Sep 17 00:00:00 2001 From: kashewnuts Date: Fri, 2 Feb 2024 15:36:53 +0900 Subject: [PATCH 2/5] migrate from setup.py to pyproject.toml --- beproud/__init__.py | 7 ----- beproud/django/__init__.py | 7 ----- pyproject.toml | 37 +++++++++++++++++++++++++++ setup.py | 52 -------------------------------------- 4 files changed, 37 insertions(+), 66 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/beproud/__init__.py b/beproud/__init__.py index 1a79358..e69de29 100644 --- a/beproud/__init__.py +++ b/beproud/__init__.py @@ -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__) diff --git a/beproud/django/__init__.py b/beproud/django/__init__.py index 1a79358..e69de29 100644 --- a/beproud/django/__init__.py +++ b/beproud/django/__init__.py @@ -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__) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b9e443a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["setuptools>=61.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "bpnotify" +version = "0.48" +authors = [ + { name="BeProud Inc.", email="project@beproud.jp" }, +] +description = "Notification routing for Django" +readme = "README.rst" +requires-python = ">=3.9" +keywords=["django"] +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.2", + "Intended Audience :: Developers", + "Environment :: Plugins", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = ["Django>=3.2", "six", "Celery"] + +[project.urls] +Homepage = "https://github.com/beproud/bpnotify/" + +[tool.setuptools.packages.find] +where = ["."] diff --git a/setup.py b/setup.py deleted file mode 100644 index 02a4dc4..0000000 --- a/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -#:coding=utf-8: - -import os -from setuptools import setup, find_packages - -def read_file(filename): - basepath = os.path.dirname(__file__) - filepath = os.path.join(basepath, filename) - with open(filepath) as f: - read_text = f.read() - return read_text - - -setup( - name='bpnotify', - version='0.48', - description='Notification routing for Django', - author='BeProud', - author_email='project@beproud.jp', - long_description=read_file('README.rst'), - long_description_content_type="text/x-rst", - url='https://github.com/beproud/bpnotify/', - python_requires='>=3.9', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Plugins', - 'Framework :: Django', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Framework :: Django', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.2', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - include_package_data=True, - packages=find_packages(), - namespace_packages=['beproud', 'beproud.django'], - test_suite='tests.main', - install_requires=[ - 'Django~=3.2', - 'Celery~=5.2', - 'six', - ], - zip_safe=False, -) From 8645f64e140de1f7d013c26fb0309ea62acdb826 Mon Sep 17 00:00:00 2001 From: kashewnuts Date: Fri, 2 Feb 2024 16:30:56 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8B=95=E4=BD=9C=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E4=B8=80=E6=97=A6setup.py=E3=81=A7?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=99=E3=82=8B=E5=BD=A2=E3=81=AB?= =?UTF-8?q?=E6=88=BB=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MANIFEST.in | 1 + beproud/__init__.py | 7 +++ beproud/django/__init__.py | 7 +++ beproud/django/notify/tests/settings.py | 3 -- setup.py | 51 +++++++++++++++++++++ test_settings.py | 60 +++++++++++++++++++++++++ tests.py | 46 +++++++++++++++++++ tox.ini | 4 +- 8 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 setup.py create mode 100644 test_settings.py create mode 100644 tests.py diff --git a/MANIFEST.in b/MANIFEST.in index 3c683ad..4a467e1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ +recursive-include beproud/django/notify/tests/templates * recursive-include beproud/django/notify/templates * recursive-include beproud/django/notify/fixtures * include README.rst diff --git a/beproud/__init__.py b/beproud/__init__.py index e69de29..1a79358 100644 --- a/beproud/__init__.py +++ b/beproud/__init__.py @@ -0,0 +1,7 @@ +# 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__) diff --git a/beproud/django/__init__.py b/beproud/django/__init__.py index e69de29..1a79358 100644 --- a/beproud/django/__init__.py +++ b/beproud/django/__init__.py @@ -0,0 +1,7 @@ +# 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__) diff --git a/beproud/django/notify/tests/settings.py b/beproud/django/notify/tests/settings.py index 7a1ebf6..10c5752 100644 --- a/beproud/django/notify/tests/settings.py +++ b/beproud/django/notify/tests/settings.py @@ -57,9 +57,6 @@ } 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' - app = celery.Celery() app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks(lambda: INSTALLED_APPS) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7bfab3c --- /dev/null +++ b/setup.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +#:coding=utf-8: + +import os +from setuptools import setup, find_packages + +def read_file(filename): + basepath = os.path.dirname(__file__) + filepath = os.path.join(basepath, filename) + with open(filepath) as f: + read_text = f.read() + return read_text + + +setup( + name='bpnotify', + version='0.48', + description='Notification routing for Django', + author='BeProud', + author_email='project@beproud.jp', + long_description=read_file('README.rst'), + long_description_content_type="text/x-rst", + url='https://github.com/beproud/bpnotify/', + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.9', + 'Framework :: Django', + 'Framework :: Django :: 2.2', + 'Framework :: Django :: 3.2', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + include_package_data=True, + packages=find_packages(), + namespace_packages=['beproud', 'beproud.django'], + test_suite='tests.main', + install_requires=[ + 'Django>=2.2', + 'django-jsonfield>=1.0.1', + 'Celery>=4.2', + 'six', + ], + zip_safe=False, +) diff --git a/test_settings.py b/test_settings.py new file mode 100644 index 0000000..47da56d --- /dev/null +++ b/test_settings.py @@ -0,0 +1,60 @@ +# 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 + +SECRET_KEY = "SECRET" +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'beproud.django.notify', +) + +# kombu.exceptions.EncodeError: Object of type User is not JSON serializable エラーを抑止する +# (参考) +# https://github.com/celery/celery/issues/5922 +# https://stackoverflow.com/questions/49373825/kombu-exceptions-encodeerror-user-is-not-json-serializable +CELERY_TASK_SERIALIZER = "pickle" + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': ':memory:', + } +} + +BASE_PATH = os.path.dirname(__file__) + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(BASE_PATH, 'beproud', 'django', 'notify', 'tests', 'templates') + ], + }, +] + +CELERY_TASK_ALWAYS_EAGER = True + +BPNOTIFY_MEDIA = { + "news": { + "verbose_name": "News", + "default_types": ("new_user", "follow", "private_msg"), + "backends": ( + "beproud.django.notify.backends.model.ModelBackend", + ), + }, + "private_messages": { + "verbose_name": "Private Message", + "default_types": ("private_msg", "notify_type_with_length_over_thirty"), + "backends": ( + "beproud.django.notify.backends.model.ModelBackend", + "beproud.django.notify.backends.mail.EmailBackend", + ), + }, +} +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' diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..8945737 --- /dev/null +++ b/tests.py @@ -0,0 +1,46 @@ +import os +import sys +import django +import celery + +import test_settings + +BASE_PATH = os.path.dirname(__file__) + + +def main(): + """ + Standalone django model test with a 'memory-only-django-installation'. + You can play with a django model without a complete django app installation. + http://www.djangosnippets.org/snippets/1044/ + """ + + # Django標準のdjango.conf.global_settingsを設定してしまうと、 + # Django3では、global_settingsの全ての定数を上書きする挙動になってしまい、 + # Django3の仕様で、多重上書き禁止エラーが検知され、例外が発生する。 + # (例) https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188 + # そのため、自前のテスト用settingsモジュール(test_settings.py)を設定する。 + os.environ["DJANGO_SETTINGS_MODULE"] = "test_settings" + + app = celery.Celery() + app.config_from_object('django.conf:settings', namespace='CELERY') + app.autodiscover_tasks(lambda: test_settings.INSTALLED_APPS) + + django.setup() + + from django.test.utils import get_runner + + # test用のsettings情報を用いて、Djangoのtest runnerクラスを取得 + TestRunner = get_runner(test_settings) + + # test runnerオブジェクトを生成 + test_runner = TestRunner() + + # test runnerにbpnotifyの単体テストのPathを渡して、bpnotifyの単体テストを実行する + failures = test_runner.run_tests(['beproud.django.notify.tests']) + + sys.exit(failures) + + +if __name__ == '__main__': + main() diff --git a/tox.ini b/tox.ini index 48ceb93..887fe0d 100644 --- a/tox.ini +++ b/tox.ini @@ -18,12 +18,14 @@ deps = pytest pytest-django pytest-pythonpath + setuptools six dj32: Django>=3.2,<4.0 dj42: Django>=4.2,<5.0 celery52: celery>=5.2,<5.3 celery53: celery>=5.3,<5.4 -commands=pytest -Wa {posargs} +# commands=pytest {posargs} +commands=python setup.py test # tox-gh-actionsパッケージの設定 [gh-actions] From 6200112fe88f4853cebd3318c1bfe30da2b863d8 Mon Sep 17 00:00:00 2001 From: kashewnuts Date: Mon, 5 Feb 2024 14:44:31 +0900 Subject: [PATCH 4/5] =?UTF-8?q?pytest&pyproject.toml=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E3=82=92=E3=82=84=E3=82=81=E3=81=A6=E3=80=81setup.py=E3=81=A7?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E6=88=BB=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beproud/django/notify/tests/__init__.py | 4 ++ beproud/django/notify/tests/settings.py | 62 ------------------------- pyproject.toml | 37 --------------- setup.py | 15 +++--- test_settings.py | 4 +- tox.ini | 6 --- 6 files changed, 14 insertions(+), 114 deletions(-) delete mode 100644 beproud/django/notify/tests/settings.py delete mode 100644 pyproject.toml diff --git a/beproud/django/notify/tests/__init__.py b/beproud/django/notify/tests/__init__.py index e69de29..49ba9c0 100644 --- a/beproud/django/notify/tests/__init__.py +++ b/beproud/django/notify/tests/__init__.py @@ -0,0 +1,4 @@ +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 diff --git a/beproud/django/notify/tests/settings.py b/beproud/django/notify/tests/settings.py deleted file mode 100644 index 10c5752..0000000 --- a/beproud/django/notify/tests/settings.py +++ /dev/null @@ -1,62 +0,0 @@ -# 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 = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'beproud.django.notify', -) - -# kombu.exceptions.EncodeError: Object of type User is not JSON serializable エラーを抑止する -# (参考) -# https://github.com/celery/celery/issues/5922 -# https://stackoverflow.com/questions/49373825/kombu-exceptions-encodeerror-user-is-not-json-serializable -CELERY_TASK_SERIALIZER = "pickle" - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - } -} - -BASE_PATH = os.path.dirname(__file__) - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - os.path.join(BASE_PATH, 'beproud', 'django', 'notify', 'tests', 'templates') - ], - }, -] - -CELERY_TASK_ALWAYS_EAGER = True - -BPNOTIFY_MEDIA = { - "news": { - "verbose_name": "News", - "default_types": ("new_user", "follow", "private_msg"), - "backends": ( - "beproud.django.notify.backends.model.ModelBackend", - ), - }, - "private_messages": { - "verbose_name": "Private Message", - "default_types": ("private_msg", "notify_type_with_length_over_thirty"), - "backends": ( - "beproud.django.notify.backends.model.ModelBackend", - "beproud.django.notify.backends.mail.EmailBackend", - ), - }, -} -BPNOTIFY_SETTINGS_STORAGE = 'beproud.django.notify.storage.db.DBStorage' - -app = celery.Celery() -app.config_from_object('django.conf:settings', namespace='CELERY') -app.autodiscover_tasks(lambda: INSTALLED_APPS) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index b9e443a..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,37 +0,0 @@ -[build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "bpnotify" -version = "0.48" -authors = [ - { name="BeProud Inc.", email="project@beproud.jp" }, -] -description = "Notification routing for Django" -readme = "README.rst" -requires-python = ">=3.9" -keywords=["django"] -classifiers = [ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.2", - "Intended Audience :: Developers", - "Environment :: Plugins", - "Topic :: Software Development :: Libraries :: Python Modules", -] -dependencies = ["Django>=3.2", "six", "Celery"] - -[project.urls] -Homepage = "https://github.com/beproud/bpnotify/" - -[tool.setuptools.packages.find] -where = ["."] diff --git a/setup.py b/setup.py index 7bfab3c..3402eb8 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,14 @@ def read_file(filename): setup( name='bpnotify', - version='0.48', + version='0.49', description='Notification routing for Django', author='BeProud', author_email='project@beproud.jp', long_description=read_file('README.rst'), long_description_content_type="text/x-rst", url='https://github.com/beproud/bpnotify/', - python_requires='>=3.6', + python_requires='>=3.9', classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Plugins', @@ -30,11 +30,13 @@ def read_file(filename): 'License :: OSI Approved :: BSD License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Framework :: Django', - 'Framework :: Django :: 2.2', 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.2', 'Topic :: Software Development :: Libraries :: Python Modules', ], include_package_data=True, @@ -42,9 +44,8 @@ def read_file(filename): namespace_packages=['beproud', 'beproud.django'], test_suite='tests.main', install_requires=[ - 'Django>=2.2', - 'django-jsonfield>=1.0.1', - 'Celery>=4.2', + 'Django>=3.2', + 'Celery>=5.2', 'six', ], zip_safe=False, diff --git a/test_settings.py b/test_settings.py index 47da56d..240e1cd 100644 --- a/test_settings.py +++ b/test_settings.py @@ -2,8 +2,6 @@ # https://github.com/django/django/blob/70035fb0444ae7c01613374212ca5e3c27c9782c/django/conf/__init__.py#L188 # そのため、testではdjango.conf.global_settingsを直接利用せず、このtest用settings定数を使用する。 -import os - SECRET_KEY = "SECRET" INSTALLED_APPS = ( 'django.contrib.auth', @@ -24,6 +22,7 @@ } } +import os BASE_PATH = os.path.dirname(__file__) TEMPLATES = [ @@ -58,3 +57,4 @@ # The name of the class to use to run the test suite TEST_RUNNER = 'django.test.runner.DiscoverRunner' + diff --git a/tox.ini b/tox.ini index 887fe0d..3891b34 100644 --- a/tox.ini +++ b/tox.ini @@ -3,11 +3,6 @@ envlist = py{39,310,311}-dj{32,42}-celery{52,53},py312-dj42-celery53 skipsdist = True -[pytest] -python_files = tests test_*.py *_tests.py -django_find_project = false -DJANGO_SETTINGS_MODULE = beproud.django.notify.tests.settings - [testenv] basepython = py39: python3.9 @@ -24,7 +19,6 @@ deps = dj42: Django>=4.2,<5.0 celery52: celery>=5.2,<5.3 celery53: celery>=5.3,<5.4 -# commands=pytest {posargs} commands=python setup.py test # tox-gh-actionsパッケージの設定 From bee212334a85597ac288edabdff750cb00ecc16f Mon Sep 17 00:00:00 2001 From: kashewnuts Date: Mon, 5 Feb 2024 16:09:34 +0900 Subject: [PATCH 5/5] =?UTF-8?q?pytest=20setup.py=20test=E3=81=AF=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=81=A7=E3=81=8D=E3=82=8B=E5=BD=A2=E3=81=A7=E6=AE=8B?= =?UTF-8?q?=E3=81=97=E3=80=81=E6=AE=8B=E3=82=8A=E3=81=AFpyproject.toml?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 37 +++++++++++++++++++++++++++++++++++ setup.py | 53 ++------------------------------------------------ 2 files changed, 39 insertions(+), 51 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bc875a9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = ["setuptools>=61.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "bpnotify" +version = "0.49" +authors = [ + { name="BeProud Inc.", email="project@beproud.jp" }, +] +description = "Notification routing for Django" +readme = "README.rst" +requires-python = ">=3.9" +keywords=["django"] +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.2", + "Intended Audience :: Developers", + "Environment :: Plugins", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = ["Django>=3.2", "six", "Celery"] + +[project.urls] +Homepage = "https://github.com/beproud/bpnotify/" + +[tool.setuptools.packages.find] +where = ["."] diff --git a/setup.py b/setup.py index 3402eb8..14667d9 100644 --- a/setup.py +++ b/setup.py @@ -1,52 +1,3 @@ -#!/usr/bin/env python -#:coding=utf-8: +from setuptools import setup -import os -from setuptools import setup, find_packages - -def read_file(filename): - basepath = os.path.dirname(__file__) - filepath = os.path.join(basepath, filename) - with open(filepath) as f: - read_text = f.read() - return read_text - - -setup( - name='bpnotify', - version='0.49', - description='Notification routing for Django', - author='BeProud', - author_email='project@beproud.jp', - long_description=read_file('README.rst'), - long_description_content_type="text/x-rst", - url='https://github.com/beproud/bpnotify/', - python_requires='>=3.9', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Plugins', - 'Framework :: Django', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Framework :: Django', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.2', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - include_package_data=True, - packages=find_packages(), - namespace_packages=['beproud', 'beproud.django'], - test_suite='tests.main', - install_requires=[ - 'Django>=3.2', - 'Celery>=5.2', - 'six', - ], - zip_safe=False, -) +setup(test_suite="tests.main")