def test_output_mismatch_actual_lineno_or_severity_without_actual():
    msg = Message("z.py", 1, 0, NOTE, "foo")
    om = OutputMismatch(expected=[msg])

    with pytest.raises(RuntimeError):
        om.actual_lineno
    with pytest.raises(RuntimeError):
        om.actual_severity
def test_output_mismatch_only_actual():
    actual = Message("z.py", 17, 3, NOTE, "foo")

    om = OutputMismatch(actual=[actual])

    assert om.lineno == actual.lineno
    assert "note" in om.error_message
    assert "unexpected" in om.error_message
    assert not om.lines
def test_output_mismatch_only_expected():
    expected = Message("z.py", 17, 3, NOTE, "foo")

    om = OutputMismatch(expected=[expected])

    assert om.lineno == expected.lineno
    assert "note" in om.error_message
    assert "missing" in om.error_message
    assert not om.lines
def test_output_mismatch_with_actual_and_expected():
    actual = Message("z.py", 17, 3, NOTE, "bar")
    expected = Message("z.py", 17, 3, NOTE, "foo")

    om = OutputMismatch(actual=[actual], expected=[expected])

    assert om.lineno == actual.lineno == expected.lineno
    assert "note" in om.error_message
    assert om.lines
def test_output_mismatch_neither_actual_nor_expected():
    with pytest.raises(ValueError):
        OutputMismatch()
def test_diff_message_sequences():
    expected = [OutputMismatch(a, e) for a, e in EXPECTED_DIFF_SEQUENCE]

    actual = diff_message_sequences(A, B)

    assert actual == expected
def test_output_mismatch_line_number_mismatch():
    msg_a = Message("z.py", 1, 0, NOTE, "foo")
    msg_b = Message("z.py", 2, 0, NOTE, "foo")

    with pytest.raises(ValueError):
        OutputMismatch([msg_a], [msg_b])