Exemple #1
0
def test_help_text(monkeypatch, capsys):
    # When
    mock_exit = mock.Mock(
        side_effect=ValueError("raised in test to exit early"))
    with mock.patch.object(sys, "exit", mock_exit), pytest.raises(
            ValueError, match="raised in test to exit early"):
        run_dryml_cli(["--help"])
    # Then
    captured = capsys.readouterr()
    assert "Provide the DRYML Document String or the Path" in captured.out
Exemple #2
0
def test_dryml_file_to_json(capsys, input_dryml_file, output_json_file):
    # Given
    with open(output_json_file) as output_json:
        expected_output_test_data_json = json.load(output_json)
    print(json.dumps(expected_output_test_data_json, indent=2))
    out, err = capsys.readouterr()
    # When
    run_dryml_cli(["dryml-to-json", input_dryml_file, "--path"])
    # Then
    captured = capsys.readouterr()
    assert captured.out == out
Exemple #3
0
def test_help_text(monkeypatch, capsys):
    # When
    mock_exit = mock.Mock(
        side_effect=ValueError("raised in test to exit early"))
    with mock.patch.object(sys, "exit", mock_exit), pytest.raises(
            ValueError, match="raised in test to exit early"):
        assert not run_dryml_cli(["--help"])
    # Then
    captured = capsys.readouterr()
    assert "usage: dryml" in captured.out
Exemple #4
0
def test_version(monkeypatch, capsys):
    # When
    mock_exit = mock.Mock(
        side_effect=ValueError("raised in test to exit early"))
    with mock.patch.object(sys, "exit", mock_exit), pytest.raises(
            ValueError, match="raised in test to exit early"):
        assert not run_dryml_cli(["--version"])
    # Then
    captured = capsys.readouterr()
    mock_exit.assert_called_with(0)
    assert main.__version__ in captured.out.strip()
Exemple #5
0
def test_simple_run(monkeypatch, capsys):
    # When
    run_dryml_cli(["dryml-to-json", "-h"])
    # Then
    captured = capsys.readouterr()
    assert "Provide the DRYML Document String or the Path" not in captured.out