def test_main_throw_exception(self, monkeypatch, capsys): def patched_argparser_parse_args(self, args): raise Exception('NOOOOOOOOOOO!') monkeypatch.setattr(argparse.ArgumentParser, 'parse_args', patched_argparser_parse_args) main() out, _ = capsys.readouterr() assert 'NOOOOOOOOOOO!' in out
def test_main(self, monkeypatch, key, name, job, exp, verify): args = [ 'test_cli.py', '--key={0}'.format(key), 'encode', 'name={0}'.format(name), 'job={0}'.format(job), ] if exp: args.append('exp={0}'.format(exp)) if verify: args.append('verify={0}'.format(verify)) monkeypatch.setattr(sys, 'argv', args) main()
def test_main(self, monkeypatch, key, name, job, exp, verify): args = [ "test_cli.py", "--key={}".format(key), "encode", "name={}".format(name), "job={}".format(job), ] if exp: args.append("exp={}".format(exp)) if verify: args.append("verify={}".format(verify)) monkeypatch.setattr(sys, "argv", args) main()
# -*- coding: utf-8 -*- import re import sys from jwt.__main__ import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())