use pytest and add pytest.ini file

This commit is contained in:
Jonathan Math 2020-11-06 14:47:41 +07:00
parent 6bd4ecb569
commit 778ee2123f
4 changed files with 19 additions and 15 deletions

View file

@ -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

View file

@ -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',
)
# ==========

View file

@ -3,7 +3,6 @@ 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'
@ -18,14 +17,19 @@ if 'test' in sys.argv:
# }
if DOCKERBUILD:
MONGO_PORT = 29019
else:
MONGO_PORT = 27017
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:27017',
}
SERVER_NAME
MONGO_DATABASE_NAME = 'test_newsblur'
# TEST_DATABASE_NAME = ":memory:"
SOUTH_TESTS_MIGRATE = False
@ -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;')

2
pytest.ini Normal file
View file

@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = newsblur_web.test_settings