Ejemplo n.º 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
Ejemplo n.º 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])
Ejemplo n.º 3
0
def test_json_output_from_string():
    root = validate_junit_xml_stream(VALID_TEST_RESULT)
    assert parse_test_result(root) == EXPECTED_JSON_OUTPUT
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 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)
Ejemplo n.º 10
0
def test_valid_junit_xml_byte_stream(encoding):
    validate_junit_xml_stream(bytes(VALID_TEST_RESULT, encoding))
Ejemplo n.º 11
0
def test_valid_junit_xml():
    validate_junit_xml_stream(VALID_TEST_RESULT)
Ejemplo n.º 12
0
def test_json_output_from_string():
    root = validate_junit_xml_stream(VALID_TEST_RESULT)
    assert ordered(parse_test_result([root])) == ordered(EXPECTED_JSON_OUTPUT)