2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-26 11:51:20 +01:00
waf/playground/pytest/wscript
2016-07-25 12:47:41 +00:00

53 lines
1.2 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
# Calle Rosenquist, 2016 (xbreak)
"""
Execute Python tests during build
To force all tests, run with "waf build --alltests"
"""
top = '.'
out = 'build'
def test_results(bld):
"""
Custom post- function that prints out test results.
"""
lst = getattr(bld, 'utest_results', [])
if not lst:
return
for (f, code, out, err) in lst:
print(out)
print(err)
def options(opt):
opt.load('python')
opt.load('waf_unit_test')
def configure(cnf):
cnf.load('python')
cnf.load('pytest')
cnf.load('waf_unit_test')
cnf.check_python_version(minver=(2, 5, 0))
def build(bld):
# Python package under test
bld(name = 'foo',
features = 'py',
source = bld.path.ant_glob('src/**/*.py'),
install_from = 'src')
# Unit test example using the built in module unittest and let that discover
# any test cases.
# By using ``foo`` the **install_path** for ``foo`` will be automatically
# added to sys.path via PYTHONPATH.
bld(features = 'pytest',
use = 'foo',
pytest_source = bld.path.ant_glob('test/*.py'),
ut_str = '${PYTHON} -B -m unittest discover')
bld.add_post_fun(test_results)