Beispiel #1
0
def test_json_output_from_byte_stream(encoding):
    root = validate_junit_xml_stream(bytes(VALID_TEST_RESULT, encoding))
    assert parse_test_result(root) == EXPECTED_JSON_OUTPUT
Beispiel #2
0
def test_invalid_junit_xml_exploits(exploit_string):
    with pytest.raises(JUnitXMLValidationError,
                       match="could not parse provided XML stream"):
        validate_junit_xml_stream(exploits[exploit_string])
Beispiel #3
0
def test_json_output_from_string():
    root = validate_junit_xml_stream(VALID_TEST_RESULT)
    assert parse_test_result(root) == EXPECTED_JSON_OUTPUT
Beispiel #4
0
def test_invalid_junit_xml_no_test_cases():
    test_string = re.sub(r"<testcase[\s\S]*?</testcase>", "",
                         VALID_TEST_RESULT)
    with pytest.raises(JUnitXMLValidationError, match="No test cases found"):
        validate_junit_xml_stream(test_string)
Beispiel #5
0
def test_invalid_junit_xml_test_case_errors(token, replacement, message):
    test_string = VALID_TEST_RESULT.replace(token, replacement)
    with pytest.raises(JUnitXMLValidationError, match=message):
        validate_junit_xml_stream(test_string)
Beispiel #6
0
def test_invalid_junit_xml_broken_xml(token, replacement):
    test_string = VALID_TEST_RESULT.replace(token, replacement)
    with pytest.raises(JUnitXMLValidationError,
                       match="could not parse provided XML stream"):
        validate_junit_xml_stream(test_string)
Beispiel #7
0
def test_invalid_junit_xml_no_metadata():
    test_string = re.sub(r"<properties>[\s\S]*?</properties>", "",
                         VALID_TEST_RESULT)
    with pytest.raises(JUnitXMLValidationError,
                       match="metadata element .* not found"):
        validate_junit_xml_stream(test_string)
Beispiel #8
0
def test_invalid_junit_xml_too_large():
    with pytest.raises(JUnitXMLValidationError,
                       match="provided stream is too large"):
        validate_junit_xml_stream("a" * int(10e7))
Beispiel #9
0
def test_invalid_junit_xml_missing_xml(input_string):
    with pytest.raises(JUnitXMLValidationError,
                       match="could not parse provided XML stream"):
        validate_junit_xml_stream(input_string)
Beispiel #10
0
def test_valid_junit_xml_byte_stream(encoding):
    validate_junit_xml_stream(bytes(VALID_TEST_RESULT, encoding))
Beispiel #11
0
def test_valid_junit_xml():
    validate_junit_xml_stream(VALID_TEST_RESULT)
def test_json_output_from_string():
    root = validate_junit_xml_stream(VALID_TEST_RESULT)
    assert ordered(parse_test_result([root])) == ordered(EXPECTED_JSON_OUTPUT)