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.')
38 parser
= argparse
.ArgumentParser(description
=description
, epilog
=epilog
)
40 'files', metavar
='FILE', nargs
='*', help=_(
41 'A file containing TAP output. Any directories listed will be '
42 'scanned for files to include as TAP files.'))
44 '-v', '--verbose', action
='store_const', default
=1, const
=2,
45 help=_('use verbose messages'))
47 # argparse expects the executable to be removed from argv.
48 args
= parser
.parse_args(argv
[1:])
50 # When no files are provided, the user wants to use a TAP stream on STDIN.
51 # But they probably didn't mean it if there is no pipe connected.
52 # In that case, print the help and exit.
53 if not args
.files
and sys
.stdin
.isatty():
54 sys
.exit(parser
.print_help())
59 def get_status(result
):
60 """Get a return status from the result."""
61 if result
.wasSuccessful():
This page took 0.034664 seconds and 5 git commands to generate.