Skip to content

Commit

Permalink
test: migrating from nose to pytest
Browse files Browse the repository at this point in the history
this commit is part of part of supporting Django 3.2
upgrade, for more context: edx/upgrades#68, the changes are:
1. Removing nose as a tool for testing
2. Adding pytest as the alternative
3. Updating the requirments to reflect 1 and 2
4  Adding a test which tests the deafult value of the Xblock model
  • Loading branch information
ghassanmas committed Sep 9, 2021
1 parent 4209ab3 commit 8204d8b
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 25 deletions.
6 changes: 0 additions & 6 deletions invideoquiz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@
},
}

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

INSTALLED_APPS = (
'django_nose',
)

SECRET_KEY = 'invideoquiz_SECRET_KEY'
Empty file removed invideoquiz/tests.py
Empty file.
15 changes: 15 additions & 0 deletions invideoquiz/tests/test_invideoquiz_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from xblock.test.tools import TestRuntime as Runtime
from xblock.runtime import DictKeyValueStore, KvsFieldData
from invideoquiz import InVideoQuizXBlock
from unittest.mock import Mock


def test_invideoquiz_model():
"""Tests for the default fields value of invideoquiz"""
key_store = DictKeyValueStore()
field_data = KvsFieldData(key_store)
runtime = Runtime(services={'field-data': field_data})
instance = InVideoQuizXBlock(runtime, scope_ids=Mock())
assert instance.display_name == 'In-Video Quiz XBlock'
assert instance.timemap == '{}'
assert instance.video_id == ''
Empty file removed invideoquiz/tests/test_travis.py
Empty file.
1 change: 0 additions & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-c constraints.txt

Django
django_nose
six
XBlock
xblock-utils
4 changes: 0 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ django==2.2.24
# via
# -c requirements/common_constraints.txt
# -r requirements/base.in
django-nose==1.4.7
# via -r requirements/base.in
fs==2.4.13
# via xblock
lxml==4.6.3
Expand All @@ -22,8 +20,6 @@ markupsafe==2.0.1
# via
# mako
# xblock
nose==1.3.7
# via django-nose
python-dateutil==2.8.2
# via xblock
pytz==2021.1
Expand Down
39 changes: 33 additions & 6 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ appdirs==1.4.4
# fs
astroid==2.7.3
# via pylint
attrs==21.2.0
# via
# -r requirements/test.txt
# pytest
coverage==5.5
# via -r requirements/test.txt
django==2.2.24
# via
# -c requirements/common_constraints.txt
# -r requirements/base.txt
django-nose==1.4.7
# via -r requirements/base.txt
fs==2.4.13
# via
# -r requirements/base.txt
# xblock
iniconfig==1.1.1
# via
# -r requirements/test.txt
# pytest
isort==5.9.3
# via pylint
lazy-object-proxy==1.6.0
Expand All @@ -43,16 +49,34 @@ mccabe==0.6.1
# via pylint
mock==4.0.3
# via -r requirements/test.txt
nose==1.3.7
packaging==21.0
# via
# -r requirements/base.txt
# django-nose
# -r requirements/test.txt
# pytest
platformdirs==2.3.0
# via pylint
pluggy==1.0.0
# via
# -r requirements/test.txt
# pytest
py==1.10.0
# via
# -r requirements/test.txt
# pytest
pycodestyle==2.7.0
# via -r requirements/quality.in
pylint==2.10.2
# via -r requirements/quality.in
pyparsing==2.4.7
# via
# -r requirements/test.txt
# packaging
pytest==6.2.5
# via
# -r requirements/test.txt
# pytest-django
pytest-django==4.4.0
# via -r requirements/test.txt
python-dateutil==2.8.2
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -81,7 +105,10 @@ sqlparse==0.4.1
# -r requirements/base.txt
# django
toml==0.10.2
# via pylint
# via
# -r requirements/test.txt
# pylint
# pytest
web-fragments==1.1.0
# via
# -r requirements/base.txt
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

coverage
mock
pytest-django
18 changes: 18 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@
#
# make upgrade
#
attrs==21.2.0
# via pytest
coverage==5.5
# via -r requirements/test.in
iniconfig==1.1.1
# via pytest
mock==4.0.3
# via -r requirements/test.in
packaging==21.0
# via pytest
pluggy==1.0.0
# via pytest
py==1.10.0
# via pytest
pyparsing==2.4.7
# via packaging
pytest==6.2.5
# via pytest-django
pytest-django==4.4.0
# via -r requirements/test.in
toml==0.10.2
# via pytest
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[metadata]
description-file = README.markdown

[nosetests]
cover-package=invideoquiz
cover-tests=1
7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ deps =
django31: Django>=3.1,<3.2
-rrequirements/test.txt
commands =
python manage.py test
pytest

[testenv:quality]
deps =
Expand All @@ -21,9 +21,6 @@ commands =
[testenv:coverage]
deps =
-rrequirements/test.txt
setenv =
NOSE_COVER_TESTS=1
NOSE_WITH_COVERAGE=1
commands =
{envpython} manage.py test
coverage run -m pytest

0 comments on commit 8204d8b

Please sign in to comment.