Skip to content

Commit

Permalink
[qa] Upgrade test suite to nose2 #61
Browse files Browse the repository at this point in the history
Closes #61
  • Loading branch information
purhan committed Jun 2, 2021
1 parent 13c892f commit 11f8ea4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: ./run-qa-checks

- name: Run tests
run: ./runtests.py
run: coverage run --source=netengine ./runtests.py

- name: Upload Coverage
run: coveralls --service=github
Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
10 changes: 5 additions & 5 deletions docs/source/topics/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ Then change the credentials accordingly, now run tests with::

See test coverage with::

nosetests --with-coverage --cover-package=netengine
nose2 --with-coverage

Run specific tests by specifying the relative path::

# base tests
nosetests tests.base
nose2 tests.base

# snmp tests
nosetests tests.snmp
nose2 tests.snmp
# snmp openwrt specific tests
nosetests tests.snmp.openwrt
nose2 tests.snmp.openwrt

# run without mocks with a custom test file
DISABLE_MOCKS=1 TEST_SETTINGS_FILE='test-settings.json' nosetests tests.snmp
DISABLE_MOCKS=1 TEST_SETTINGS_FILE='test-settings.json' nose2 tests.snmp
3 changes: 2 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
nose~=1.3.7
nose2~=0.10.0
coverage~=5.5
sphinx~=4.0.2
openwisp-utils[qa]~=0.7.4
pylinkvalidator~=0.3.0
11 changes: 11 additions & 0 deletions run-qa-checks
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ openwisp-qa-check --skip-checkmigrations
# test sphinx docs
mkdir -p docs/source/_static
make -C docs html

PYTHON_VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
if [[ $PYTHON_VERSION != 3.6 ]]; then
# check for broken links
# remove condition when 3.6 is dropped
python -m http.server 8001 -d docs/build/html/ &>/dev/null &
pid=$!
sleep 4
pylinkvalidate.py http://localhost:8001/
kill "${pid}" 2> /dev/null || true
fi
12 changes: 3 additions & 9 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

try:
import nose
import nose2
except ImportError:
message = """nose package not installed, install test requirements with:
pip install -r requirements-test.txt
Expand All @@ -14,11 +14,5 @@
if __name__ == '__main__':
file_path = os.path.abspath(__file__)
tests_path = os.path.join(os.path.abspath(os.path.dirname(file_path)), 'tests',)
result = nose.main(
argv=[
os.path.abspath(__file__),
'--with-cov',
'--cover-package=netengine',
tests_path,
]
)
nose2.discover()
result = nose2.main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def get_install_requires():
'Programming Language :: Python',
'Topic :: System :: Networking',
],
test_suite='nose.collector',
test_suite='nose2.collector.collector',
)

0 comments on commit 11f8ea4

Please sign in to comment.