From 94baa515d3b63864fb0f1a5fc8f82b2c2226feb1 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 13 Oct 2016 11:01:04 -0500 Subject: Add the ttrun command --- setup.cfg | 4 ++++ tox.ini | 3 --- ttrun/cmd.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 ttrun/cmd.py diff --git a/setup.cfg b/setup.cfg index 483e178..fe41412 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,3 +20,7 @@ classifier = [files] packages = ttrun + +[entry_points] +console_scripts = + ttrun = ttrun.cmd:main diff --git a/tox.ini b/tox.ini index ecd1bd3..3cf0182 100644 --- a/tox.ini +++ b/tox.ini @@ -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 diff --git a/ttrun/cmd.py b/ttrun/cmd.py new file mode 100644 index 0000000..a237b1b --- /dev/null +++ b/ttrun/cmd.py @@ -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 . + +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()) -- cgit v1.2.3