Files
anybadge/tasks/test.py
Jon Grace-Cox 1c986d4ad8 Add package testing to CI (#68)
* Make `build_examples.py` callable from python
* Allow tests to run from outside project directory
* Add invoke tasks
* Add server tests
* Run travis tests against wheel package instead of local code
* Update `badge.write_badge()` to support `pathlib.Path`
* Update `CONTRIBUTING.md`
2022-08-13 13:22:15 -04:00

33 lines
775 B
Python

import subprocess
from pathlib import Path
from invoke import task
PROJECT_DIR = Path(__file__).parent.parent
@task
def local(c):
"""Run local tests."""
print("Running local tests...")
subprocess.run(
"pytest --doctest-modules --cov=anybadge --cov-report html:htmlcov anybadge tests",
shell=True,
)
@task
def docker(c):
"""Run dockerised tests."""
print("Running containerised tests...")
subprocess.run("invoke clean", shell=True)
subprocess.run("invoke build", shell=True)
subprocess.run(
f"(cd docker/test && docker build . -t test-anybadge:latest)", shell=True
)
subprocess.run(
f"docker run -v {PROJECT_DIR}:/app test-anybadge:latest /work/run_docker_tests.sh",
shell=True,
)