How to use subcommand_test method in tox

Best Python code snippet using tox_python

main.py

Source:main.py Github

copy

Full Screen

1import argparse2import pathlib3import sys4import traceback5from logging import DEBUG, INFO, StreamHandler, basicConfig, getLogger6from typing import *7import onlinejudge.__about__ as api_version8import onlinejudge_command.__0_workaround_for_conflict # pylint: disable=unused-import9import onlinejudge_command.__about__ as version10import onlinejudge_command.log_formatter as log_formatter11import onlinejudge_command.subcommand.download as subcommand_download12import onlinejudge_command.subcommand.generate_input as subcommand_generate_input13import onlinejudge_command.subcommand.generate_output as subcommand_generate_output14import onlinejudge_command.subcommand.login as subcommand_login15import onlinejudge_command.subcommand.submit as subcommand_submit16import onlinejudge_command.subcommand.test as subcommand_test17import onlinejudge_command.subcommand.test_reactive as subcommand_test_reactive18import onlinejudge_command.update_checking as update_checking19import onlinejudge_command.utils as utils20logger = getLogger(__name__)21def get_parser() -> argparse.ArgumentParser:22 parser = argparse.ArgumentParser(23 description='Tools for online judge services',24 formatter_class=argparse.RawTextHelpFormatter,25 epilog='''\26tips:27 The official tutorial exists on the web: https://github.com/online-judge-tools/oj/blob/master/docs/getting-started.md28''',29 )30 parser.add_argument('-v', '--verbose', action='store_true')31 parser.add_argument('-c', '--cookie', type=pathlib.Path, default=utils.default_cookie_path, help='path to cookie. (default: {})'.format(utils.default_cookie_path))32 parser.add_argument('--version', action='store_true', help='print the online-judge-tools version number')33 subparsers = parser.add_subparsers(dest='subcommand', help='for details, see "{} COMMAND --help"'.format(sys.argv[0]))34 subcommand_download.add_subparser(subparsers)35 subcommand_login.add_subparser(subparsers)36 subcommand_submit.add_subparser(subparsers)37 subcommand_test.add_subparser(subparsers)38 subcommand_generate_output.add_subparser(subparsers)39 subcommand_generate_input.add_subparser(subparsers)40 subcommand_test_reactive.add_subparser(subparsers)41 return parser42def run_program(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:43 if args.version:44 print('online-judge-tools {} (+ online-judge-api-client {})'.format(version.__version__, api_version.__version__))45 return 046 logger.debug('args: %s', str(args))47 # print the version to use for user-supporting48 logger.info('online-judge-tools %s (+ online-judge-api-client %s)', version.__version__, api_version.__version__)49 # TODO: make functions for subcommand take a named tuple instead of the raw result of argparse. Using named tuples make code well-typed.50 if args.subcommand in ['download', 'd', 'dl']:51 if not subcommand_download.run(args):52 return 153 elif args.subcommand in ['login', 'l']:54 if not subcommand_login.run(args):55 return 156 elif args.subcommand in ['submit', 's']:57 if not subcommand_submit.run(args):58 return 159 elif args.subcommand in ['test', 't']:60 if not subcommand_test.run(args):61 return 162 elif args.subcommand in ['test-reactive', 't/r', 'test-interactive', 't/i']:63 if not subcommand_test_reactive.run(args):64 return 165 elif args.subcommand in ['generate-output', 'g/o']:66 subcommand_generate_output.run(args)67 elif args.subcommand in ['generate-input', 'g/i']:68 subcommand_generate_input.run(args)69 else:70 parser.print_help(file=sys.stderr)71 return 172 return 073def main(args: Optional[List[str]] = None) -> 'NoReturn':74 parser = get_parser()75 parsed = parser.parse_args(args=args)76 # configure the logger77 level = INFO78 if parsed.verbose:79 level = DEBUG80 handler = StreamHandler(sys.stdout)81 handler.setFormatter(log_formatter.LogFormatter())82 basicConfig(level=level, handlers=[handler])83 # check update84 is_updated = update_checking.run()85 try:86 sys.exit(run_program(parsed, parser=parser))87 except NotImplementedError as e:88 logger.debug('\n' + traceback.format_exc())89 logger.error('NotImplementedError')90 logger.info('The operation you specified is not supported yet. Pull requests are welcome.')91 logger.info('see: https://github.com/online-judge-tools/oj')92 if not is_updated:93 logger.info(utils.HINT + 'try updating the version of online-judge-tools: $ pip3 install -U online-judge-tools online-judge-api-client')94 sys.exit(1)95 except Exception as e:96 logger.debug('\n' + traceback.format_exc())97 logger.exception(str(e))98 if not is_updated:99 logger.info(utils.HINT + 'try updating the version of online-judge-tools: $ pip3 install -U online-judge-tools online-judge-api-client')100 sys.exit(1)101if __name__ == '__main__':...

Full Screen

Full Screen

hacks.py

Source:hacks.py Github

copy

Full Screen

...16def subcommand_test_monkeypatch(post):17 """Monkeypatch Tox session to call a hook when commands finish."""18 import tox.session19 real_subcommand_test = tox.session.Session.subcommand_test20 def subcommand_test(self):21 retcode = real_subcommand_test(self)22 post(self.config)23 return retcode...

Full Screen

Full Screen

test_hacks.py

Source:test_hacks.py Github

copy

Full Screen

...12 real_subcommand_test = tox.session.Session.subcommand_test13 # Python 2 compat14 real_subcommand_test = getattr(15 real_subcommand_test, '__func__', real_subcommand_test)16 assert real_subcommand_test(session) == 4217 subcommand_test.assert_called_once_with(session)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful