From 778ee2123fc9f3a3ceb991df91aa789e427c6e15 Mon Sep 17 00:00:00 2001 From: Jonathan Math Date: Fri, 6 Nov 2020 14:47:41 +0700 Subject: [PATCH] use pytest and add pytest.ini file --- config/requirements.txt | 4 +--- newsblur_web/settings.py | 3 +-- newsblur_web/test_settings.py | 25 +++++++++++++++---------- pytest.ini | 2 ++ 4 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 pytest.ini diff --git a/config/requirements.txt b/config/requirements.txt index 11a44e38c..bf1ec4341 100755 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -10,7 +10,6 @@ django-compress==1.0.1 django-cors-middleware==1.3.1 django-extensions==2.2.9 django-mailgun==0.9.1 -django-nose==1.4.7 django-oauth-toolkit==1.2.0 django-qurl==0.1.1 django-paypal==1.0 @@ -35,8 +34,6 @@ mongoengine==0.20.0 PyMySQL==0.9.3 ndg-httpsclient==0.4.2 nltk==3.4.5 -nose==1.3.7 -nose-exclude==0.5.0 numpy==1.18.5 oauth2==1.9.0.post1 pillow==7.0.0 @@ -48,6 +45,7 @@ pyflakes==1.3.0 pymongo==3.4.0 pymysql==0.9.3 pyopenssl>=17.5.0 +pytest==6.1.2 python-dateutil==2.6.0 python-digitalocean==1.13.2 python-gflags==3.1.0 diff --git a/newsblur_web/settings.py b/newsblur_web/settings.py index f3b8612a9..a5bf3f5d3 100644 --- a/newsblur_web/settings.py +++ b/newsblur_web/settings.py @@ -269,7 +269,7 @@ INTERNAL_IPS = ('127.0.0.1',) LOGGING_LOG_SQL = True APPEND_SLASH = False SESSION_ENGINE = 'redis_sessions.session' -TEST_RUNNER = "django_nose.NoseTestSuiteRunner" +TEST_RUNNER = "utils.testrunner.TestRunner" SESSION_COOKIE_NAME = 'newsblur_sessionid' SESSION_COOKIE_AGE = 60*60*24*365*10 # 10 years SESSION_COOKIE_DOMAIN = '.newsblur.com' @@ -338,7 +338,6 @@ INSTALLED_APPS = ( 'vendor.zebra', 'oauth2_provider', 'corsheaders', - 'django_nose', ) # ========== diff --git a/newsblur_web/test_settings.py b/newsblur_web/test_settings.py index 67118a0ca..3e03cd337 100644 --- a/newsblur_web/test_settings.py +++ b/newsblur_web/test_settings.py @@ -3,11 +3,10 @@ from newsblur_web.settings import * DOCKERBUILD = os.getenv("DOCKERBUILD") -if 'test' in sys.argv: - DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' - DATABASES['default']['OPTIONS'] = {} - DATABASES['default']['NAME'] = 'nb.db' - DATABASES['default']['TEST_NAME'] = 'nb2.db' +DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' +DATABASES['default']['OPTIONS'] = {} +DATABASES['default']['NAME'] = 'nb.db' +DATABASES['default']['TEST_NAME'] = 'nb2.db' # DATABASES = { # 'default':{ @@ -18,13 +17,18 @@ if 'test' in sys.argv: # } if DOCKERBUILD: MONGO_PORT = 29019 + MONGO_DB = { + 'name': 'newsblur_test', + 'host': '127.0.0.1:29019', + } + else: MONGO_PORT = 27017 - -MONGO_DB = { - 'name': 'newsblur_test', - 'host': '127.0.0.1:29019', -} + MONGO_DB = { + 'name': 'newsblur_test', + 'host': '127.0.0.1:27017', + } + SERVER_NAME MONGO_DATABASE_NAME = 'test_newsblur' # TEST_DATABASE_NAME = ":memory:" @@ -36,6 +40,7 @@ DEBUG = True SITE_ID = 2 RAVEN_CLIENT = None HOMEPAGE_USERNAME = 'conesus' +SERVER_NAME = 'test_newsblur' # from django.db import connection # cursor = connection.cursor() # cursor.execute('PRAGMA temp_store = MEMORY;') diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..d57429fc8 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = newsblur_web.test_settings \ No newline at end of file