コード例 #1
0
ファイル: test_core.py プロジェクト: perfa/py-x
 def test_should_append_tests_to_xml_output(self):
     suite = XunitSuite("my_name")
     test = test_mock()
     suite.append(test)                
     
     xml = suite.to_xml()
     assert_that(xml[0], is_(test.to_xml()))
コード例 #2
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_report_id_in_xml_tag_if_one_is_provided(self):
        suite = XunitSuite("my_name")
        result = suite.to_xml(id=2)
        assert_that(result.attrib['id'], is_("2"))

        result = suite.to_xml(id=8)
        assert_that(result.attrib['id'], is_("8"))
コード例 #3
0
ファイル: test_core.py プロジェクト: perfa/py-x
 def test_should_report_name_in_xml_tag_as_name_attribute(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml()
     assert_that(result.attrib['name'], is_("my_name"))
     
     suite = XunitSuite("different_suite")
     result = suite.to_xml()
     assert_that(result.attrib['name'], is_("different_suite"))
コード例 #4
0
ファイル: test_core.py プロジェクト: perfa/py-x
 def test_should_report_package_in_xml_tag_as_package_attribute_if_present(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml()
     assert_that('package' in result.attrib, is_(False), "shouldn't have package attribute")
     
     suite = XunitSuite("my_name", package="Pack1")
     result = suite.to_xml()
     assert_that(result.attrib['package'], is_("Pack1"))
コード例 #5
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_maintain_count_of_passing_tests(self):
        suite = XunitSuite("testsuite")
        test1 = Mock(XunitTest)

        assert_that(suite.number_passing, is_(0))
        suite.append(test1)
        assert_that(suite.number_passing, is_(1))
        suite.append(test1)
        assert_that(suite.number_passing, is_(2))
コード例 #6
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_aggregate_test_results(self):
        suite = XunitSuite("testsuite")
        test1 = Mock(XunitTest)

        assert_that(suite.test_count, is_(0))
        suite.append(test1)
        assert_that(suite.test_count, is_(1))
        suite.append(test1)
        assert_that(suite.test_count, is_(2))
コード例 #7
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_report_total_time_in_xml_tag_as_time_attribute(self):
        test = test_mock()
        suite = XunitSuite("my_name")
        result = suite.to_xml()

        assert_that(result.attrib['time'], is_("0.0"))

        suite.append(test)
        result = suite.to_xml()
        assert_that(result.attrib['time'], is_("1.5"))
コード例 #8
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_report_skip_count_in_xml_tag_as_skipped_attribute(self):
        test = test_mock("skipped")
        suite = XunitSuite("my_name")
        result = suite.to_xml()
        
        assert_that(result.attrib['skipped'], is_("0"))

        suite.append(test)
        result = suite.to_xml()
        assert_that(result.attrib['skipped'], is_("1"))
コード例 #9
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_maintain_count_of_tests_that_were_skipped(self):
        suite = XunitSuite("skip_suite")
        test1 = Mock(XunitTest)
        test1.passed = False
        test1.status = "skipped"

        assert_that(suite.skipped_count, is_(0))
        
        suite.append(test1)
        assert_that(suite.skipped_count, is_(1))
コード例 #10
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_aggregate_run_time_of_tests(self):
        suite = XunitSuite("testsuite")
        test1 = XunitTest("test", time=0.5)

        assert_that(suite.total_time, is_(0.0))
        
        suite.append(test1)
        assert_that(suite.total_time, is_(0.5))
 
        suite.append(test1)
        assert_that(suite.total_time, is_(1.0))
コード例 #11
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_create_xml_that_is_valid_according_to_the_JUnit_jenkins_schema(self):
        test = XunitTest("test1")
        suite = XunitSuite("suite1")
        suite.append(test)
        result = Xunit()
        result.append(suite)

        try:
            xml = etree.fromstring(result.to_string(), PARSER)
        except etree.XMLSyntaxError as err:
            print(str(err))
            self.fail("Should have parsed without errors")
        else:
            pass
コード例 #12
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_aggregate_test_counts_from_all_suites(self):
        suite = XunitSuite("name")
        test_mock = Mock(XunitTest)
        suite.append(test_mock)
        suite.append(test_mock)
        results = Xunit()
        
        results.append(suite)
        assert_that(results.total_test_count, is_(2))

        results.append(suite)
        assert_that(results.total_test_count, is_(4))

        suite.append(test_mock)
        assert_that(results.total_test_count, is_(6))
コード例 #13
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_maintain_count_of_tests_that_had_errors(self):
        suite = XunitSuite("errorsuite")
        test1 = Mock(XunitTest)
        test1.passed = False
        test1.status = "error"
        assert_that(suite.error_count, is_(0))
        
        suite.append(test1)
        assert_that(suite.error_count, is_(1))
        
        test2 = Mock(XunitTest)
        test2.passed = False
        test2.status = "failed"
 
        suite.append(test2)
        assert_that(suite.error_count, is_(1))
コード例 #14
0
ファイル: __init__.py プロジェクト: perfa/py-x
def from_yaml(yaml_input):
    """Parse provided yaml and instantiate an Xunit object from that"""
    report_description = yaml.load(yaml_input)
    report = Xunit()

    for test_suite, data in report_description.items():
        suite = XunitSuite(test_suite)
        report.append(suite)

        if data is None:
            continue

        for test, test_data in data.items():
            test_result = XunitTest(test, test_suite)
            if test_data and 'status' in test_data:
                test_result.status = test_data['status']
            suite.append(test_result)

    return report
コード例 #15
0
ファイル: test_core.py プロジェクト: perfa/py-x
 def test_should_report_empty_package_if_none_was_provided_and_force_package_is_used(self):
     suite = XunitSuite("my_name")
     result = suite.to_xml(force_package=True)
     assert_that(result.attrib['package'], is_(""))
コード例 #16
0
ファイル: test_core.py プロジェクト: perfa/py-x
    def test_should_create_testsuite_node_as_xml_output(self):
        suite = XunitSuite("testsuite")
        result = suite.to_xml()

        assert_that(result.tag, is_("testsuite"))