diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-01 14:11:11 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-01 16:23:05 -0500 |
commit | 5e1472b67dee6b4bddd240968a6ff152dba5f3b9 (patch) | |
tree | e82f0b18bc68262cba877543d3b93f7a94f255f7 /noxfile.py | |
parent | fce732d3e404f06c78563fabb36cd565e2a98eab (diff) | |
download | requests-cache-5e1472b67dee6b4bddd240968a6ff152dba5f3b9.tar.gz |
Use nox to run tests in GitHub Actions
Diffstat (limited to 'noxfile.py')
-rw-r--r-- | noxfile.py | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -1,5 +1,8 @@ -"""Notes: -* 'test-<python version>' commands: nox will use poetry.lock to determine dependency versions +"""Runner script for tools used in local development and CI. + +Notes: +* 'test' and 'test-<python version>' commands: nox will create separate virtualenvs per python + version, and use `poetry.lock` to determine dependency versions * 'lint' command: tools and environments are managed by pre-commit * All other commands: the current environment will be used instead of creating new ones * Run `nox -l` to see all available commands @@ -18,25 +21,32 @@ LIVE_DOCS_IGNORE = ['*.pyc', '*.tmp', join('**', 'modules', '*')] LIVE_DOCS_WATCH = ['requests_cache', 'examples'] CLEAN_DIRS = ['dist', 'build', join('docs', '_build'), join('docs', 'modules')] +PYTHON_VERSIONS = ['3.7', '3.8', '3.9', '3.10'] UNIT_TESTS = join('tests', 'unit') INTEGRATION_TESTS = join('tests', 'integration') STRESS_TEST_MULTIPLIER = 10 -COVERAGE_ARGS = ( - '--cov --cov-report=term --cov-report=html' # Generate HTML + stdout coverage report -) -XDIST_ARGS = '--numprocesses=auto --dist=loadfile' # Run tests in parallel, grouped by test module +# Generate HTML + stdout coverage report +COVERAGE_ARGS = '--cov --cov-report=term --cov-report=html' +# Run tests in parallel, grouped by test module +XDIST_ARGS = '--numprocesses=auto --dist=loadfile' -@session(python=['3.7', '3.8', '3.9', '3.10']) +@session(python=PYTHON_VERSIONS) def test(session): - """Run tests for a specific python version""" - test_paths = session.posargs or [UNIT_TESTS] + """Run tests in a separate virtualenv per python version""" + test_paths = session.posargs or [UNIT_TESTS, INTEGRATION_TESTS] session.install('.', 'pytest', 'pytest-xdist', 'requests-mock', 'timeout-decorator') - cmd = f'pytest -rs {XDIST_ARGS}' + cmd = f'pytest -rs -x {XDIST_ARGS}' session.run(*cmd.split(' '), *test_paths) +@session(python=False, name='test-current') +def test_current(session): + """Run tests using the current virtualenv""" + test(session) + + @session(python=False) def clean(session): """Clean up temporary build + documentation files""" @@ -48,10 +58,8 @@ def clean(session): @session(python=False, name='cov') def coverage(session): """Run tests and generate coverage report""" - cmd_1 = f'pytest {UNIT_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS}' - cmd_2 = f'pytest {INTEGRATION_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS} --cov-append' - session.run(*cmd_1.split(' ')) - session.run(*cmd_2.split(' ')) + cmd = f'pytest {UNIT_TESTS} {INTEGRATION_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS}' + session.run(*cmd.split(' ')) @session(python=False, name='stress') |