1 # Copyright (c) 2016, Matt Layman
8 from tap
.loader
import Loader
11 def main(argv
=sys
.argv
, stream
=sys
.stderr
):
12 """Entry point for ``tappy`` command."""
13 args
= parse_args(argv
)
14 suite
= build_suite(args
)
15 runner
= unittest
.TextTestRunner(verbosity
=args
.verbose
, stream
=stream
)
16 result
= runner
.run(suite
)
18 return get_status(result
)
21 def build_suite(args
):
22 """Build a test suite by loading TAP files or a TAP stream."""
24 if len(args
.files
) == 0 or args
.files
[0] == '-':
25 suite
= loader
.load_suite_from_stdin()
27 suite
= loader
.load(args
.files
)
32 description
= _('A TAP consumer for Python')
34 'When no files are given or a dash (-) is used for the file name, '
35 'tappy will read a TAP stream from STDIN.')
36 parser
= argparse
.ArgumentParser(description
=description
, epilog
=epilog
)
38 'files', metavar
='FILE', nargs
='*', help=_(
39 'A file containing TAP output. Any directories listed will be '
40 'scanned for files to include as TAP files.'))
42 '-v', '--verbose', action
='store_const', default
=1, const
=2,
43 help=_('use verbose messages'))
45 # argparse expects the executable to be removed from argv.
46 args
= parser
.parse_args(argv
[1:])
48 # When no files are provided, the user wants to use a TAP stream on STDIN.
49 # But they probably didn't mean it if there is no pipe connected.
50 # In that case, print the help and exit.
51 if not args
.files
and sys
.stdin
.isatty():
52 sys
.exit(parser
.print_help())
57 def get_status(result
):
58 """Get a return status from the result."""
59 if result
.wasSuccessful():
This page took 0.030819 seconds and 4 git commands to generate.