def remove_cd(): """ Remove file in current directory. """ with pun.cd('./tests'): pun.run('rm file')
def environ(): """ Print env. """ with pun.env('pun_env', 34): pun.run(print, os.environ['pun_env'])
def touch_cd(): """ Create file in current directory. """ with pun.cd('./tests'): pun.run('touch file')
def run(): """ Run server """ webbrowser.open("http://127.0.0.1:5000") pun.run('flask run -h 0.0.0.0')
def init(): """ Create an empty punfile. """ pun.run('touch punfile.py') with open('punfile.py', 'w') as fp: fp.write(init_template)
def clean_build(): """ Remove build artifacts. """ pun.run("rm -fr build/") pun.run("rm -fr dist/") pun.run("rm -fr .eggs/") pun.run("find . -name '*.egg-info' -exec rm -fr {} +") pun.run("find . -name '*.egg' -exec rm -f {} +")
def help(punned): """ Show list of task and their description. """ # make default to None for printing helper default = punned.default punned.default = None pun.run(punned.run) punned.default = default
def clean_pyc(): """ Remove Python file artifacts. """ pun.run("find . -name '*.pyc' -exec rm -f {} +") pun.run("find . -name '*.pyo' -exec rm -f {} +") pun.run("find . -name '*~' -exec rm -f {} +") pun.run("find . -name '__pycache__' -exec rm -fr {} +")
def clean_test(): """ Remove test and coverage artifacts. """ pun.run("rm -fr .tox/") pun.run("rm -f .coverage") pun.run("rm -fr htmlcov/") pun.run("rm -fr .pytest_cache")
def coverage(): """ Check code coverage quickly with the default Python. """ pun.run("coverage run --source pun -m pytest") pun.run("coverage report -m") pun.run("coverage html") pun.run(browser, "htmlcov/index.html")
def dist(): """ Builds source and wheel package. """ pun.run("python setup.py sdist") pun.run("python setup.py bdist_wheel") pun.run("ls -l dist")
def docs(): """ Generate Sphinx HTML documentation, including API docs. """ pun.run("rm -f docs/pun.rst") pun.run("rm -f docs/modules.rst") pun.run("sphinx-apidoc -o docs/ pun") with pun.cd('./docs'): pun.run("make clean") pun.run("make html") pun.run(browser, "docs/_build/html/index.html")
def option(): """ Called with --option """ pun.run(print, 'optioned')
def release(): """ Package and upload a release. """ pun.run('twine upload dist/*')
def touch(): """ Create file in current directory. """ pun.run('touch file')
def test(): """ Run tests quickly with the default Python. """ pun.run('pytest')
def need_fixture3(one, two, three): """ This task need three fixture. """ pun.run(print, one() + two() + three())
def version(): """ Show pun version. """ pun.run(print, f'pun version {pun.__version__}')
def need_fixture1(one): """ This task need one fixture. """ pun.run(print, one())
def default(): """ This should executed when no arg. """ pun.run('echo default')
def install(): """ Install the package to the active Python's site-packages. """ pun.run('pip install .')
def remove(): """ Remove file in current directory. """ pun.run('rm file')
def need_fixture4(one, two, three, four): """ This task need three fixture. """ pun.run(print, one() + two() + three() + four())
def lint(): """ Check style with flake8. """ pun.run('flake8 pun tests')
def no_fixture(undefined): """ Fail because no fixture named 'undefined'. """ pun.run(print, undefined())
def test_all(): """ Run tests on every Python version with tox. """ pun.run('tox')
def punned_fixture(punned): """ Fail because no fixture named 'undefined'. """ pun.run(print, punned)
def need_fixture2(one, two): """ This task need two fixture. """ pun.run(print, one() + two())
def install_dev(): """ Install the package for development. """ pun.run('pip install -e .')