예제 #1
0
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
예제 #2
0
"""
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())
예제 #3
0
"""
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
예제 #4
0
def test_main():
    assert main([]) == 0
예제 #5
0
def test_main_with_KeyboardInterrupt(mock_parsecli):
    mock_parsecli.side_effect = KeyboardInterrupt
    result = main([rng2doc.__package__, "fake.rng"])
    assert result == errorcode(KeyboardInterrupt())
예제 #6
0
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())
예제 #7
0
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__)
예제 #8
0
def test_help():
    with pytest.raises(SystemExit):
        main(["", "--help"])
예제 #9
0
def test_invalid():
    assert main(["", "--wrong-option"]) == errorcode(DocoptExit())
예제 #10
0
def test_main():
    assert main([]) == errorcode(DocoptExit())