示例#1
0
    def test_single_suite_no_test_cases_utf8(self):
        properties = {'foö': 'bär'}
        package = 'mypäckage'
        timestamp = 1398382805

        test_suite = TestSuite(name='äöü',
                               test_cases=[],
                               hostname='löcalhost',
                               id='äöü',
                               properties=properties,
                               package=package,
                               timestamp=timestamp)
        (ts, tcs) = serialize_and_read(test_suite,
                                       to_file=True,
                                       prettyprint=True,
                                       encoding='utf-8')[0]
        self.assertEqual(ts.tagName, 'testsuite')
        self.assertEqual(ts.attributes['package'].value,
                         decode(package, 'utf-8'))
        self.assertEqual(ts.attributes['timestamp'].value, str(timestamp))
        self.assertEqual(
            ts.childNodes[0].childNodes[0].attributes['name'].value,
            decode('foö', 'utf-8'))
        self.assertEqual(
            ts.childNodes[0].childNodes[0].attributes['value'].value,
            decode('bär', 'utf-8'))
示例#2
0
    def test_single_suite_no_test_cases_utf8(self):
        properties = {'foö': 'bär'}
        package = 'mypäckage'
        timestamp = 1398382805

        test_suite = TestSuite(
                'äöü',
                [],
                hostname='löcalhost',
                id='äöü',
                properties=properties,
                package=package,
                timestamp=timestamp
            )
        (ts, tcs) = serialize_and_read(
            test_suite,
            to_file=True,
            prettyprint=True,
            encoding='utf-8'
        )[0]
        self.assertEqual(ts.tagName, 'testsuite')
        self.assertEqual(ts.attributes['package'].value, decode(package, 'utf-8'))
        self.assertEqual(ts.attributes['timestamp'].value, str(timestamp))
        self.assertEqual(
            ts.childNodes[0].childNodes[0].attributes['name'].value,
            decode('foö', 'utf-8'))
        self.assertEqual(
            ts.childNodes[0].childNodes[0].attributes['value'].value,
            decode('bär', 'utf-8'))
示例#3
0
def test_single_suite_no_test_cases_utf8():
    properties = {"foö": "bär"}
    package = "mypäckage"
    timestamp = 1398382805

    test_suite = Suite(
        name="äöü",
        test_cases=[],
        hostname="löcalhost",
        id="äöü",
        properties=properties,
        package=package,
        timestamp=timestamp,
    )
    #pylint: disable=unused-variable
    ts, tcs = serialize_and_read(test_suite,
                                 to_file=True,
                                 prettyprint=True,
                                 encoding="utf-8")[0]
    assert ts.tagName == "testsuite"
    assert ts.attributes["package"].value == decode(package, "utf-8")
    assert ts.attributes["timestamp"].value == str(timestamp)
    assert ts.childNodes[0].childNodes[0].attributes["name"].value == decode(
        "foö", "utf-8")
    assert ts.childNodes[0].childNodes[0].attributes["value"].value == decode(
        "bär", "utf-8")
示例#4
0
def test_init_utf8():
    tc = Case(
        name="Test äöü",
        classname="some.class.name.äöü",
        elapsed_sec=123.345,
        stdout="I am stdöüt!",
        stderr="I am stdärr!",
    )
    tc.add_skipped_info(message="Skipped äöü", output="I skippäd!")
    tc.add_error_info(message="Skipped error äöü",
                      output="I skippäd with an error!")
    test_suite = Suite("Test UTF-8", [tc])
    ts, tcs = serialize_and_read(test_suite, encoding="utf-8")[0]
    verify_test_case(
        tcs[0],
        {
            "name": decode("Test äöü", "utf-8"),
            "classname": decode("some.class.name.äöü", "utf-8"),
            "time": ("%f" % 123.345),
        },
        stdout=decode("I am stdöüt!", "utf-8"),
        stderr=decode("I am stdärr!", "utf-8"),
        skipped_message=decode("Skipped äöü", "utf-8"),
        skipped_output=decode("I skippäd!", "utf-8"),
        error_message=decode("Skipped error äöü", "utf-8"),
        error_output=decode("I skippäd with an error!", "utf-8"),
    )
示例#5
0
    def build_xml_doc(self, encoding=None):
        xml_element = \
            super(self.__class__, self).build_xml_doc(encoding=encoding)

        for idx, case in enumerate(xml_element):
            for stdout in self.test_cases[idx].multiple_stdout:
                stdout_element = ET.SubElement(case, "system-out")
                stdout_element.text = decode(stdout, encoding)

        return xml_element
示例#6
0
 def test_init_utf8(self):
     tc = TestCase('Test äöü', 'some.class.name.äöü', 123.345, 'I am stdöüt!', 'I am stdärr!')
     tc.add_skipped_info(message='Skipped äöü', output="I skippäd!")
     tc.add_error_info(message='Skipped error äöü', output="I skippäd with an error!")
     test_suite = TestSuite('Test UTF-8', [tc])
     (ts, tcs) = serialize_and_read(test_suite, encoding='utf-8')[0]
     verify_test_case(self, tcs[0], {'name': decode('Test äöü', 'utf-8'),
                                     'classname': decode('some.class.name.äöü', 'utf-8'),
                                     'time': ("%f" % 123.345)},
                     stdout=decode('I am stdöüt!', 'utf-8'), stderr=decode('I am stdärr!', 'utf-8'),
                     skipped_message=decode('Skipped äöü', 'utf-8'),
                     skipped_output=decode('I skippäd!', 'utf-8'),
                     error_message=decode('Skipped error äöü', 'utf-8'),
                     error_output=decode('I skippäd with an error!', 'utf-8'))
示例#7
0
 def test_init_utf8(self):
     tc = TestCase('Test äöü', 'some.class.name.äöü', 123.345,
                   'I am stdöüt!', 'I am stdärr!')
     tc.add_skipped_info(message='Skipped äöü', output="I skippäd!")
     tc.add_error_info(message='Skipped error äöü',
                       output="I skippäd with an error!")
     test_suite = TestSuite('Test UTF-8', [tc])
     (ts, tcs) = serialize_and_read(test_suite, encoding='utf-8')[0]
     verify_test_case(
         self,
         tcs[0], {
             'name': decode('Test äöü', 'utf-8'),
             'classname': decode('some.class.name.äöü', 'utf-8'),
             'time': ("%f" % 123.345)
         },
         stdout=decode('I am stdöüt!', 'utf-8'),
         stderr=decode('I am stdärr!', 'utf-8'),
         skipped_message=decode('Skipped äöü', 'utf-8'),
         skipped_output=decode('I skippäd!', 'utf-8'),
         error_message=decode('Skipped error äöü', 'utf-8'),
         error_output=decode('I skippäd with an error!', 'utf-8'))
示例#8
0
def test_single_suite_no_test_cases_unicode():
    properties = {decode("foö", "utf-8"): decode("bär", "utf-8")}
    package = decode("mypäckage", "utf-8")
    timestamp = 1398382805

    ts, tcs = serialize_and_read(
        Suite(
            name=decode("äöü", "utf-8"),
            test_cases=[],
            hostname=decode("löcalhost", "utf-8"),
            id=decode("äöü", "utf-8"),
            properties=properties,
            package=package,
            timestamp=timestamp,
        ),
        to_file=True,
        prettyprint=True,
        encoding="utf-8",
    )[0]
    assert ts.tagName == "testsuite"
    assert ts.attributes["package"].value == package
    assert ts.attributes["timestamp"].value, str(timestamp)
    assert ts.childNodes[0].childNodes[0].attributes["name"].value == decode("foö", "utf-8")
    assert ts.childNodes[0].childNodes[0].attributes["value"].value == decode("bär", "utf-8")
示例#9
0
    def test_init_unicode(self):
        tc = TestCase(decode('Test äöü', 'utf-8'), decode('some.class.name.äöü', 'utf-8'), 123.345,
                      decode('I am stdöüt!', 'utf-8'), decode('I am stdärr!', 'utf-8'))
        tc.add_skipped_info(message=decode('Skipped äöü', 'utf-8'),
                            output=decode('I skippäd!', 'utf-8'))
        tc.add_error_info(message=decode('Skipped error äöü', 'utf-8'),
                          output=decode('I skippäd with an error!', 'utf-8'))

        (ts, tcs) = serialize_and_read(TestSuite('Test Unicode',
                                                 [tc]))[0]
        verify_test_case(self, tcs[0], {'name': decode('Test äöü', 'utf-8'),
                                        'classname': decode('some.class.name.äöü', 'utf-8'),
                                        'time': ("%f" % 123.345)},
                        stdout=decode('I am stdöüt!', 'utf-8'), stderr=decode('I am stdärr!', 'utf-8'),
                        skipped_message=decode('Skipped äöü', 'utf-8'),
                        skipped_output=decode('I skippäd!', 'utf-8'),
                        error_message=decode('Skipped error äöü', 'utf-8'),
                        error_output=decode('I skippäd with an error!', 'utf-8'))
示例#10
0
    def test_init_unicode(self):
        tc = TestCase(name=decode('Test äöü', 'utf-8'),
                      classname=decode('some.class.name.äöü', 'utf-8'),
                      elapsed_sec=123.345,
                      stdout=decode('I am stdöüt!', 'utf-8'),
                      stderr=decode('I am stdärr!', 'utf-8'))
        tc.add_skipped_info(message=decode('Skipped äöü', 'utf-8'),
                            output=decode('I skippäd!', 'utf-8'))
        tc.add_error_info(message=decode('Skipped error äöü', 'utf-8'),
                          output=decode('I skippäd with an error!', 'utf-8'))

        (ts, tcs) = serialize_and_read(TestSuite('Test Unicode', [tc]))[0]
        verify_test_case(
            self,
            tcs[0], {
                'name': decode('Test äöü', 'utf-8'),
                'classname': decode('some.class.name.äöü', 'utf-8'),
                'time': ("%f" % 123.345)
            },
            stdout=decode('I am stdöüt!', 'utf-8'),
            stderr=decode('I am stdärr!', 'utf-8'),
            skipped_message=decode('Skipped äöü', 'utf-8'),
            skipped_output=decode('I skippäd!', 'utf-8'),
            error_message=decode('Skipped error äöü', 'utf-8'),
            error_output=decode('I skippäd with an error!', 'utf-8'))
示例#11
0
def test_init_unicode():
    tc = Case(
        name=decode("Test äöü", "utf-8"),
        classname=decode("some.class.name.äöü", "utf-8"),
        elapsed_sec=123.345,
        stdout=decode("I am stdöüt!", "utf-8"),
        stderr=decode("I am stdärr!", "utf-8"),
    )
    tc.add_skipped_info(message=decode("Skipped äöü", "utf-8"),
                        output=decode("I skippäd!", "utf-8"))
    tc.add_error_info(message=decode("Skipped error äöü", "utf-8"),
                      output=decode("I skippäd with an error!", "utf-8"))

    #pylint: disable=unused-variable
    ts, tcs = serialize_and_read(Suite("Test Unicode", [tc]))[0]
    verify_test_case(
        tcs[0],
        {
            "name": decode("Test äöü", "utf-8"),
            "classname": decode("some.class.name.äöü", "utf-8"),
            "time": ("%f" % 123.345),
        },
        stdout=decode("I am stdöüt!", "utf-8"),
        stderr=decode("I am stdärr!", "utf-8"),
        skipped_message=decode("Skipped äöü", "utf-8"),
        skipped_output=decode("I skippäd!", "utf-8"),
        error_message=decode("Skipped error äöü", "utf-8"),
        error_output=decode("I skippäd with an error!", "utf-8"),
    )