1 # SPDX-License-Identifier: BSD-2-Clause
3 # Copyright (c) 2016, Matt Layman
10 from tap
.loader
import Loader
13 def main(argv
=sys
.argv
, stream
=sys
.stderr
):
14 """Entry point for ``tappy`` command."""
15 args
= parse_args(argv
)
16 suite
= build_suite(args
)
17 runner
= unittest
.TextTestRunner(verbosity
=args
.verbose
, stream
=stream
)
18 result
= runner
.run(suite
)
20 return get_status(result
)
23 def build_suite(args
):
24 """Build a test suite by loading TAP files or a TAP stream."""
26 if len(args
.files
) == 0 or args
.files
[0] == '-':
27 suite
= loader
.load_suite_from_stdin()
29 suite
= loader
.load(args
.files
)
34 description
= _('A TAP consumer for Python')
36 'When no files are given or a dash (-) is used for the file name, '
37 'tappy will read a TAP stream from STDIN.'
39 parser
= argparse
.ArgumentParser(description
=description
, epilog
=epilog
)
45 'A file containing TAP output. Any directories listed will be '
46 'scanned for files to include as TAP files.'
55 help=_('use verbose messages'),
58 # argparse expects the executable to be removed from argv.
59 args
= parser
.parse_args(argv
[1:])
61 # When no files are provided, the user wants to use a TAP stream on STDIN.
62 # But they probably didn't mean it if there is no pipe connected.
63 # In that case, print the help and exit.
64 if not args
.files
and sys
.stdin
.isatty():
65 sys
.exit(parser
.print_help())
70 def get_status(result
):
71 """Get a return status from the result."""
72 if result
.wasSuccessful():
This page took 0.029687 seconds and 4 git commands to generate.