Beispiel #1
0
    def test_setup_fail(self):
        """Check that py.test setup failures are handled"""
        body = '<testcase classname="_test.test_event" name="test_simple" time="0">' \
             + '<error message="test setup failure">request = &lt;FuncargRequest for &lt;Function...</error>' \
             + '</testcase>'
        filename = self._xml_file(body, errors=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('error', elem.attr['status'])
        self.assertEqual(1, len(elem.children))

        trace = elem.children[0]
        self.assertEqual('traceback', trace.name)
        self.assertEqual(1, len(trace.children))
        self.assertEqual('request = <FuncargRequest for <Function...',
                         trace.children[0])

        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.ERROR, type)

        self.assertEqual(0, len(self.ctxt.output))
Beispiel #2
0
    def test_setup_fail(self):
        """Check that py.test setup failures are handled"""
        body = '<testcase classname="_test.test_event" name="test_simple" time="0">' \
             + '<error message="test setup failure">request = &lt;FuncargRequest for &lt;Function...</error>' \
             + '</testcase>'
        filename = self._xml_file(body, errors=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('error', elem.attr['status'])
        self.assertEqual(1, len(elem.children))

        trace = elem.children[0]
        self.assertEqual('traceback', trace.name)
        self.assertEqual(1, len(trace.children))
        self.assertEqual('request = <FuncargRequest for <Function...', trace.children[0])

        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual(Recipe.ERROR, type)

        self.assertEqual(0, len(self.ctxt.output))
Beispiel #3
0
    def test_simple(self):
        body = '<testcase classname="_test.test_event" name="test_simple" time="0.0002"></testcase>'
        filename = self._xml_file(body, tests=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('success', elem.attr['status'])
        self.assertEqual(0, len(elem.children))
Beispiel #4
0
    def test_simple(self):
        body = '<testcase classname="_test.test_event" name="test_simple" time="0.0002"></testcase>'
        filename = self._xml_file(body, tests=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('success', elem.attr['status'])
        self.assertEqual(0, len(elem.children))
Beispiel #5
0
 def test_parse_and_compare_formats(self):
     # parse xml_template1
     f1 = self._create_file('junit1.xml', content=self.xml_template1)
     javatools.junit(self.ctxt, file_=f1)
     type1, category1, generator1, xml1 = self.ctxt.output.pop()
     self.assertEqual('report', type1)
     self.assertEqual('test', category1)
     # parse xml_template2
     f2 = self._create_file('junit2.xml', content=self.xml_template2)
     javatools.junit(self.ctxt, file_=f2)
     type2, category2, generator2, xml2 = self.ctxt.output.pop()
     self.assertEqual('report', type2)
     self.assertEqual('test', category2)
     # compare
     for i in range(2):
         self.assertEquals(xml1.children[i].name, xml2.children[i].name)
         self.assertEquals(xml1.children[i].attr, xml2.children[i].attr)
Beispiel #6
0
 def test_parse_and_compare_formats(self):
     # parse xml_template1
     f1 = self._create_file('junit1.xml', content=self.xml_template1)
     javatools.junit(self.ctxt, file_=f1)
     type1, category1, generator1, xml1 = self.ctxt.output.pop()
     self.assertEqual('report', type1)
     self.assertEqual('test', category1)
     # parse xml_template2
     f2 = self._create_file('junit2.xml', content=self.xml_template2)
     javatools.junit(self.ctxt, file_=f2)
     type2, category2, generator2, xml2 = self.ctxt.output.pop()
     self.assertEqual('report', type2)
     self.assertEqual('test', category2)
     # compare
     for i in range(2):
         self.assertEquals(xml1.children[i].name, xml2.children[i].name)
         self.assertEquals(xml1.children[i].attr, xml2.children[i].attr)
Beispiel #7
0
    def test_skipped_tests(self):
        """Check that skipped tests (here: xfail in py.test) are not considered an error"""
        body = '<testcase classname="_test.test_event" name="test_simple" time="0.06">' \
             + '<skipped/></testcase>'
        filename = self._xml_file(body, skips=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('ignore', elem.attr['status'])
        self.assertEqual(1, len(elem.children))

        trace = elem.children[0]
        self.assertEqual('traceback', trace.name)
        self.assertEqual(0, len(trace.children))

        self.assertEqual(0, len(self.ctxt.output))
Beispiel #8
0
    def test_skipped_tests(self):
        """Check that skipped tests (here: xfail in py.test) are not considered an error"""
        body = '<testcase classname="_test.test_event" name="test_simple" time="0.06">' \
             + '<skipped/></testcase>'
        filename = self._xml_file(body, skips=1)
        javatools.junit(self.ctxt, file_=filename)
        type, category, generator, xml = self.ctxt.output.pop()
        self.assertEqual('report', type)
        self.assertEqual('test', category)
        self.assertEqual(1, len(xml.children))

        elem = xml.children[0]
        self.assertEqual('test', elem.name)
        self.assertEqual('test_simple', elem.attr['name'])
        self.assertEqual('ignore', elem.attr['status'])
        self.assertEqual(1, len(elem.children))

        trace = elem.children[0]
        self.assertEqual('traceback', trace.name)
        self.assertEqual(0, len(trace.children))

        self.assertEqual(0, len(self.ctxt.output))