Add the ttrun command

This commit is contained in:
Monty Taylor 2016-10-13 11:01:04 -05:00
parent 968571920b
commit 94baa515d3
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
3 changed files with 52 additions and 3 deletions

View File

@ -20,3 +20,7 @@ classifier =
[files]
packages =
ttrun
[entry_points]
console_scripts =
ttrun = ttrun.cmd:main

View File

@ -22,9 +22,6 @@ commands = {posargs}
commands = python setup.py test --coverage --testr-args='{posargs}'
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build

48
ttrun/cmd.py Normal file
View 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())