def test_checkargs_empty_rng(mock_exists, mock_parse): def xmltree(source, parser=None, base_url=None): return etree.XML("""""").getroottree() mock_exists.return_value = True mock_parse.side_effect = xmltree assert main(['fake.rng']) == 20
""" Entrypoint module, in case you use `python -mrng2doc`. Why does this file exist, and why __main__? For more info, read: - https://www.python.org/dev/peps/pep-0338/ - https://docs.python.org/2/using/cmdline.html#cmdoption-m - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ import sys from rng2doc.cli import main if __name__ == "__main__": sys.exit(main())
""" Entrypoint module, in case you use `python -mrng2doc`. Why does this file exist, and why __main__? For more info, read: - https://www.python.org/dev/peps/pep-0338/ - https://docs.python.org/2/using/cmdline.html#cmdoption-m - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ if __name__ == "__main__": import sys from rng2doc.cli import main sys.exit(main()) # pragma: no cover
def test_main(): assert main([]) == 0
def test_main_with_KeyboardInterrupt(mock_parsecli): mock_parsecli.side_effect = KeyboardInterrupt result = main([rng2doc.__package__, "fake.rng"]) assert result == errorcode(KeyboardInterrupt())
def test_main_notfound_rng(mock_exists): from docopt import DocoptExit mock_exists.return_value = False result = main([rng2doc.__package__, "fake.rng"]) assert result == errorcode(DocoptExit())
def test_main_with_version(capsys): """Checks for correct version""" with pytest.raises(SystemExit): main([rng2doc.__package__, "--version"]) out, _ = capsys.readouterr() assert out == "{} {}\n".format(rng2doc.__package__, rng2doc.__version__)
def test_help(): with pytest.raises(SystemExit): main(["", "--help"])
def test_invalid(): assert main(["", "--wrong-option"]) == errorcode(DocoptExit())
def test_main(): assert main([]) == errorcode(DocoptExit())