Exemple #1
0
 def test_version(self, capsys):
     with pytest.raises(SystemExit) as e:
         _parse_arguments(["--version"])
     assert e.value.code == 0
     del e  # explicitly break reference cycle
     out, err = capsys.readouterr()
     assert err == ""
     assert out == "{}\n".format(__version__)
Exemple #2
0
 def test_help(self, capsys):
     expected_progname = os.path.basename(sys.argv[0])
     with pytest.raises(SystemExit) as e:
         _parse_arguments(["--help"])
     assert e.value.code == 0
     del e  # explicitly break reference cycle
     out, err = capsys.readouterr()
     assert err == ""
     initial_paragraph, rest = out.split("\n\n", 1)
     assert re.match("usage:\s*{}\s*"
         "\[-h\]\s*"
         "\[--input-file INPUT_FILE\]\s*"
         "\[--output-file OUTPUT_FILE\]\s*"
         "\[--version\]\s*"
         "proc-name".format(expected_progname), initial_paragraph)
     assert rest == """\
Exemple #3
0
 def test_sys_argv(self, monkeypatch):
     test_func_name = "I intend to live forever. So far, so good."
     monkeypatch.setattr(sys, "argv", [sys.argv[0], test_func_name])
     expected = test_func_name, None, None
     assert _parse_arguments(_UndefinedParam) == expected
Exemple #4
0
 def test_error(self, argv):
     with pytest.raises(SystemExit) as e:
         _parse_arguments(argv)
     assert e.value.code == 2
     del e  # explicitly break reference cycle
Exemple #5
0
 def test(self, argv, proc_name, input_file, output_file):
     assert _parse_arguments(argv) == (proc_name, input_file, output_file)