Skip to content

Commit 49d3037

Browse files
author
Renzo Lucioni
committed
Use pytest to run tests
Having been in maintenance mode for the past several years, nose is effectively dead. edX and the Python community at large are moving towards pytest. pytest is actively developed and provides several benefits over nose, including detailed introspection of failing assert statements (no need to use unittest's assert methods), a rich plugin ecosystem, and modular fixtures (which may help move us away from relying on migrations for populating initial test data).
1 parent 4ece08a commit 49d3037

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ private.py
8282
# pyenv
8383
.python-version
8484

85+
# Visual Studio Code
86+
.vscode
87+
8588
*.trace
8689

90+
.cache/
91+
credentials/media/
8792
credentials/static/bundles/
8893
docs/_build/
8994
node_modules/
90-
credentials/media/
9195
webpack-stats.json
92-
93-
94-
# Visual Studio Code
95-
.vscode

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ clean_static:
4545

4646
production-requirements:
4747
npm install --production
48-
pip install -r requirements.txt --exists-action w
48+
pip install -r requirements.txt
4949

5050
requirements:
5151
npm install
5252
pip install -r requirements/local.txt
5353

5454
test: clean
55-
coverage run ./manage.py test credentials --settings=credentials.settings.test
55+
coverage run -m pytest
5656
coverage report
5757

5858
quality:
@@ -74,7 +74,7 @@ static.watch:
7474
serve:
7575
python manage.py runserver 0.0.0.0:8150
7676

77-
validate: test quality
77+
validate: quality test
7878

7979
migrate:
8080
python manage.py migrate

credentials/settings/test.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,13 @@
55
from credentials.settings.base import *
66
from credentials.settings.utils import get_logger_config
77

8-
# TEST SETTINGS
8+
99
INSTALLED_APPS += [
10-
'django_nose',
1110
'credentials.apps.edx_credentials_extensions',
1211
]
1312

14-
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
15-
16-
NOSE_ARGS = [
17-
'--with-ignore-docstrings',
18-
'--logging-level=DEBUG',
19-
]
20-
# LOGGING
2113
LOGGING = get_logger_config(debug=False, dev_env=True, local_loglevel='DEBUG')
22-
# END TEST SETTINGS
23-
2414

25-
# IN-MEMORY TEST DATABASE
2615
DATABASES = {
2716
'default': {
2817
'ENGINE': 'django.db.backends.sqlite3',
@@ -33,15 +22,13 @@
3322
'PORT': '',
3423
},
3524
}
36-
# END IN-MEMORY TEST DATABASE
3725

3826
# Local Directories
39-
TEST_ROOT = path("test_root")
27+
TEST_ROOT = path('test_root')
4028
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
41-
MEDIA_ROOT = TEST_ROOT / "uploads"
42-
MEDIA_URL = "/static/uploads/"
29+
MEDIA_ROOT = TEST_ROOT / 'uploads'
30+
MEDIA_URL = '/static/uploads/'
4331

44-
# AUTHENTICATION
4532
OAUTH2_PROVIDER_URL = 'https://test-provider/oauth2'
4633
SOCIAL_AUTH_EDX_OIDC_URL_ROOT = OAUTH2_PROVIDER_URL
4734

@@ -50,4 +37,3 @@
5037
'JWT_ISSUER': OAUTH2_PROVIDER_URL,
5138
'JWT_AUDIENCE': SOCIAL_AUTH_EDX_OIDC_KEY,
5239
})
53-
# END AUTHENTICATION

pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
DJANGO_SETTINGS_MODULE = credentials.settings.test
3+
testpaths = credentials/apps

requirements/test.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
bok-choy==0.6.1
55
coverage==4.3.4
66
ddt==1.1.1
7-
django-nose==1.4.4
87
edx-lint==0.5.2
98
factory-boy==2.8.1
109
httpretty==0.8.14
1110
isort==4.2.5
1211
mock==2.0.0
13-
nose-ignore-docstring==0.2
1412
pep8==1.7.0
13+
pytest==3.0.7
14+
pytest-django==3.1.2
1515
responses==0.5.1
1616
testfixtures==4.13.4

0 commit comments

Comments
 (0)