Add the ttrun command
This commit is contained in:
@@ -20,3 +20,7 @@ classifier =
|
|||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
ttrun
|
ttrun
|
||||||
|
|
||||||
|
[entry_points]
|
||||||
|
console_scripts =
|
||||||
|
ttrun = ttrun.cmd:main
|
||||||
|
3
tox.ini
3
tox.ini
@@ -22,9 +22,6 @@ commands = {posargs}
|
|||||||
commands = python setup.py test --coverage --testr-args='{posargs}'
|
commands = python setup.py test --coverage --testr-args='{posargs}'
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
|
||||||
|
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125
|
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||||
|
48
ttrun/cmd.py
Normal file
48
ttrun/cmd.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright (c) 2016 Red Hat, Inc
|
||||||
|
#
|
||||||
|
# This file is part of ttrun
|
||||||
|
#
|
||||||
|
# ttrun is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# ttrun is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
|
def parse_arguments():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Simple CLI to run tests with testtools')
|
||||||
|
parser.add_argument(
|
||||||
|
'-e', dest='environment', help='tox environment to use')
|
||||||
|
parser.add_argument('tests', nargs='*', help='Tests to run')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.environment:
|
||||||
|
return subprocess.call([
|
||||||
|
'.tox/{environment}/bin/python'.format(
|
||||||
|
environment=args.environment),
|
||||||
|
'-m',
|
||||||
|
'testtools.run'] + args.tests)
|
||||||
|
else:
|
||||||
|
return testtools.run.main([sys.argv[0]] + args.tests, sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
Reference in New Issue
Block a user