From 11f8ea47390f84e773995bd1735aa3ab5ce4e013 Mon Sep 17 00:00:00 2001 From: purhan Date: Tue, 1 Jun 2021 23:12:14 +0530 Subject: [PATCH] [qa] Upgrade test suite to nose2 #61 Closes #61 --- .github/workflows/ci.yml | 2 +- docs/source/index.rst | 1 - docs/source/topics/usage.rst | 10 +++++----- requirements-test.txt | 3 ++- run-qa-checks | 11 +++++++++++ runtests.py | 12 +++--------- setup.py | 2 +- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe0b830..fae03d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/docs/source/index.rst b/docs/source/index.rst index c1a8c0b..0c70a47 100755 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -69,5 +69,4 @@ Indices and tables ================== * :ref:`genindex` -* :ref:`modindex` * :ref:`search` diff --git a/docs/source/topics/usage.rst b/docs/source/topics/usage.rst index 988b6c3..b3a5baa 100755 --- a/docs/source/topics/usage.rst +++ b/docs/source/topics/usage.rst @@ -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 diff --git a/requirements-test.txt b/requirements-test.txt index cde44ed..fed2167 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -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 diff --git a/run-qa-checks b/run-qa-checks index 0736593..329fdbb 100755 --- a/run-qa-checks +++ b/run-qa-checks @@ -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 diff --git a/runtests.py b/runtests.py index a5a43a4..6493dbb 100755 --- a/runtests.py +++ b/runtests.py @@ -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 @@ -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() diff --git a/setup.py b/setup.py index 5874d25..8d69b17 100755 --- a/setup.py +++ b/setup.py @@ -45,5 +45,5 @@ def get_install_requires(): 'Programming Language :: Python', 'Topic :: System :: Networking', ], - test_suite='nose.collector', + test_suite='nose2.collector.collector', )