def reporter_options(): opts = utils.parse_options([ 'style = dark', 'verbose=yes', 'quiet=no', 'switch=on', 'bigbutton=off', 'bool=true', 'lie=false', 'num=3', 'list=1,2,3', 'pair=foo:bar', 'dict=foo:bar,abc:123', 'notopt', 'empty=', 'void=none', 'hyphens-are-ok=true', ]) assert opts == dict( style='dark', verbose=True, quiet=False, switch=True, bigbutton=False, bool=True, lie=False, num=3, list=(1, 2, 3), pair=dict(foo='bar'), dict=dict(foo='bar', abc=123), empty=None, void=None, hyphens_are_ok=True, )
def main(tests=None, **kwargs): parser = make_parser(**kwargs) options, args = parser.parse_args() # When run as a console script (i.e. ``attest``), the CWD isn't # ``sys.path[0]``, but it should be. It's important to do this early in # case custom reporters are being used that make the assumption that CWD is # on ``sys.path``. cwd = os.getcwd() if sys.path[0] not in ('', cwd): sys.path.insert(0, cwd) if options.list_reporters: for reporter in get_all_reporters(): print reporter return opts = parse_options(args) reporter = get_reporter_by_name(options.reporter)(**opts) if not tests: names = [arg for arg in args if '=' not in arg] if not names: names = [ name for name in os.listdir('.') if path.isfile('%s/__init__.py' % name) ] if options.native_assert: tests = Tests(names) else: with AssertImportHook(): tests = Tests(names) def run(): tests.run(reporter, full_tracebacks=options.full_tracebacks, fail_fast=options.fail_fast, debugger=options.debugger, no_capture=options.no_capture, keyboard_interrupt=options.keyboard_interrupt) if options.profile: filename = options.profile import cProfile cProfile.runctx('run()', globals(), locals(), filename) print 'Wrote profiling results to %r.' % (filename, ) else: run()
def main(tests=None, **kwargs): parser = make_parser(**kwargs) options, args = parser.parse_args() # When run as a console script (i.e. ``attest``), the CWD isn't # ``sys.path[0]``, but it should be. It's important to do this early in # case custom reporters are being used that make the assumption that CWD is # on ``sys.path``. cwd = os.getcwd() if sys.path[0] not in ('', cwd): sys.path.insert(0, cwd) if options.list_reporters: for reporter in get_all_reporters(): print reporter return opts = parse_options(args) reporter = get_reporter_by_name(options.reporter)(**opts) if not tests: names = [arg for arg in args if '=' not in arg] if not names: names = [name for name in os.listdir('.') if path.isfile('%s/__init__.py' % name)] if options.native_assert: tests = Tests(names) else: with AssertImportHook(): tests = Tests(names) def run(): tests.run(reporter, full_tracebacks=options.full_tracebacks, fail_fast=options.fail_fast, debugger=options.debugger, no_capture=options.no_capture, keyboard_interrupt=options.keyboard_interrupt) if options.profile: filename = options.profile import cProfile cProfile.runctx('run()', globals(), locals(), filename) print 'Wrote profiling results to %r.' % (filename,) else: run()
def main(tests=None, **kwargs): parser = make_parser(**kwargs) options, args = parser.parse_args() if options.list_reporters: for reporter in get_all_reporters(): print reporter return opts = parse_options(args) reporter = get_reporter_by_name(options.reporter)(**opts) if not tests: sys.path.insert(0, os.getcwd()) names = [arg for arg in args if '=' not in arg] if not names: names = [name for name in os.listdir('.') if path.isfile('%s/__init__.py' % name)] if options.native_assert: tests = Tests(names) else: with AssertImportHook(): tests = Tests(names) def run(): tests.run(reporter, full_tracebacks=options.full_tracebacks, fail_fast=options.fail_fast, debugger=options.debugger, no_capture=options.no_capture, keyboard_interrupt=options.keyboard_interrupt) if options.profile: filename = options.profile import cProfile cProfile.runctx('run()', globals(), locals(), filename) print 'Wrote profiling results to %r.' % (filename,) else: run()
def reporter_options(): opts = utils.parse_options( [ "style = dark", "verbose=yes", "quiet=no", "switch=on", "bigbutton=off", "bool=true", "lie=false", "num=3", "list=1,2,3", "pair=foo:bar", "dict=foo:bar,abc:123", "notopt", "empty=", "void=none", "hyphens-are-ok=true", ] ) assert opts == dict( style="dark", verbose=True, quiet=False, switch=True, bigbutton=False, bool=True, lie=False, num=3, list=(1, 2, 3), pair=dict(foo="bar"), dict=dict(foo="bar", abc=123), empty=None, void=None, hyphens_are_ok=True, )