-
Notifications
You must be signed in to change notification settings - Fork 4
/
tasks.py
48 lines (37 loc) · 927 Bytes
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
import os
import sys
import webbrowser
from invoke import task
docs_dir = 'docs'
build_dir = os.path.join(docs_dir, '_build')
@task
def test(ctx, watch=False, last_failing=False):
"""Run the tests.
Note: --watch requires pytest-xdist to be installed.
"""
import pytest
flake(ctx)
args = []
if watch:
args.append('-f')
if last_failing:
args.append('--lf')
retcode = pytest.main(args)
sys.exit(retcode)
@task
def flake(ctx):
"""Run flake8 on codebase."""
ctx.run('flake8 .', echo=True)
@task
def clean(ctx):
ctx.run('rm -rf build')
ctx.run('rm -rf dist')
ctx.run('rm -rf django-include.egg-info')
print('Cleaned up.')
@task
def readme(ctx, browse=False):
"""Build README.rst. Requires Sphinx."""
ctx.run("rst2html.py README.rst > README.html")
if browse:
webbrowser.open_new_tab('README.html')