Skip to content

Commit

Permalink
invoke: 'test' and 'cov'
Browse files Browse the repository at this point in the history
  • Loading branch information
pyroscope committed Feb 23, 2020
1 parent 4da7774 commit bd47aad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 39 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Common Development Tasks

Here are some common project tasks::

pytest # Run unittests
invoke docs -o # Build documentation and show in browser
paver lint -m # Check code quality
paver cov # Run unittests & show coverage report
tox # Run unittests in various test environments (multiple Python versions)
pytest # Run unittests
inv docs -o # Build documentation and show in browser
paver lint -m # Check code quality
inv cov # Run unittests & show coverage report
tox # Run unittests in various test environments (multiple Python versions)


.. _`Mastering Issues`: https://guides.github.com/features/issues/
Expand Down
34 changes: 0 additions & 34 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,44 +107,10 @@ def bootstrap():
"initialize project"


@task
@needs("docs")
def dist_docs():
"create a documentation bundle"
dist_dir = path("dist")
docs_package = path("%s/%s-%s-docs.zip" % (dist_dir.abspath(), options.setup.name, options.setup.version))

dist_dir.exists() or dist_dir.makedirs()
docs_package.exists() and docs_package.remove()

sh(r'cd build/apidocs && zip -qr9 %s .' % (docs_package,))

print('')
print("Upload @ http://pypi.python.org/pypi?:action=pkg_edit&name=%s" % ( options.setup.name,))
print(docs_package)


#
# Testing
#

PYTEST_CMD = 'python -m pytest'

@task
def test():
"run unit tests"
sh(PYTEST_CMD)


@task
def cov():
"generate coverage report and show in browser"
coverage_index = path("build/coverage/index.html")
coverage_index.remove()
sh(PYTEST_CMD)
coverage_index.exists() and webbrowser.open(
'file://{}'.format(os.path.abspath(coverage_index)))

@task
@needs("setuptools.command.build")
def functest():
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ twine==3.1.1; python_version >= "3.6"
zipp==1.2.0; python_version < "3.6"
more-itertools==5.0.0; python_version < "3"
more-itertools==8.2.0; python_version >= "3.5"
pathlib2; python_version < "3"

invoke==1.4.1
tox==3.14.5
Expand Down
21 changes: 21 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,35 @@
import shutil
import subprocess
import webbrowser
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path

from invoke import task


PROJECT_NAME = 'pyrobase'
PYTEST_CMD = 'python -m pytest'
SPHINX_AUTOBUILD_PORT = int(os.environ.get('SPHINX_AUTOBUILD_PORT', '8340'))


@task
def test(ctx):
"""Run unit tests."""
ctx.run(PYTEST_CMD)


@task
def cov(ctx):
"""Run unit tests & show coverage report"""
coverage_index = Path("build/coverage/index.html")
coverage_index.unlink()
ctx.run(PYTEST_CMD)
coverage_index.exists() and webbrowser.open(
'file://{}'.format(os.path.abspath(coverage_index)))


def watchdog_pid(ctx):
"""Get watchdog PID via ``netstat``."""
result = ctx.run('netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}'
Expand Down

0 comments on commit bd47aad

Please sign in to comment.