Example #1
0
 def testAdd3(self):
     name1 = "test1"
     name2 = "test2"
     self.exceptionMessage = "Invalid channel class name:"
     self.assertRaises(TypeError, channels.add, "TestClass1", "test1")
     channels.register(TestClass1)
     className1 = TestClass1.__name__
     channels.add(className1, name1)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, className1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length + 1)
Example #2
0
 def testAdd3(self):
     name1 = "test1"
     name2 = "test2"
     self.exceptionMessage = "Invalid channel class name:"
     self.assertRaises(TypeError, channels.add, "TestClass1", "test1")
     channels.register(TestClass1)
     className1 = TestClass1.__name__
     channels.add(className1, name1)
     self.assertTrue(name1 in channels._cache)
     self.assertEqual(TestClass1, channels._cache[name1][0])
     length = len(channels._cache)
     self.exceptionMessage = "Channel with such a name already exists:"
     self.assertRaises(ValueError, channels.add, className1, name1)
     channels.add(TestClass1, name2)
     self.assertEqual(len(channels._cache), length+1)
Example #3
0
    def stopTest(self, result, device):
        '''
        Processes a test stop execution for the summary channel.
        '''
        TestResultChannel.stopTest(self, result, device)
        if isinstance(result, TestCaseResult):
            self._counters[STATUS_NOT_COMPLETED] -= 1
            self._counters[device.status] += 1
            self._counters[_STOP_STAMP] = time.time()
        if device.cores:
            self._counters[COUNTER_CORE_DUMPS] += len(device.cores)

    def getSummary(self):
        '''
        Gets a summary of test results.
        '''
        runTime = self._counters[_STOP_STAMP] - self._counters[_START_STAMP]
        summary = {
            COUNTER_RUN_TIME: utils.runTimeToString(runTime),
            COUNTER_N_TESTS: self._counters[COUNTER_N_TESTS],
            COUNTER_TESTS_RUN: self._counters[COUNTER_TESTS_RUN],
            COUNTER_CORE_DUMPS: self._counters[COUNTER_CORE_DUMPS]
        }
        # Copy all status counters except STATUS_NO_RUN
        for status in STATUS_COUNTERS[1:]:
            summary[status] = self._counters[status]
        return summary

register(SummaryChannel)

        self.write(self._format(result, formatters["start"], formatters,
                                self._deviceAttrs(device)))
        self.write(self._formatResult(result, formatters,
                                      self._deviceAttrs(device)))

    def stopTest(self, result, device):
        '''
        Processes a test stop execution for the stream channel.
        '''
        TestResultChannel.stopTest(self, result, device)
        formatters = (self._verboseFormats if self.isVerbose()
                                           else self._simpleFormats)
        self.write(self._format(result, formatters["stop"], formatters,
                                self._deviceAttrs(device)))
        self.write(self._formatResult(result, formatters,
                                      self._deviceAttrs(device)))
        self.write(self._format(device.cores, formatters["cores"],
                                formatters, self._basicAttrs(device)))
        self.write(self._format(device.errors, formatters["errors"],
                                formatters, self._basicAttrs(device)))

    def write(self, data):
        '''
        Writes the given data to the stream.
        '''
        if data:
            self._stream.write(utils.encode(data, self._encoding))

register(StreamChannel)

Example #5
0
## to Comarch before any contribution is made. You should have received       ##
## a copy of Contribution Agreement along with TADEK bundled with this file   ##
## in the file CONTRIBUTION_AGREEMENT.pdf or see http://tadek.comarch.com     ##
## or write to [email protected]                                     ##
##                                                                            ##
################################################################################

from tadek.engine import channels
from tadek.engine.channels import TestResultChannel

class TestClass01(TestResultChannel):
    def __init__(self, name, **params):
        self.name = name
        self.params = params

channels.register(TestClass01)


class TestClass11(TestResultChannel):
    def __init__(self, name, **params):
        self.name = name
        self.params = params

channels.register(TestClass11)


class TestClass02(object):
    def __init__(self, name, **params):
        self.name = name
        self.params = params
Example #6
0
 def testRegister(self):
     self.assertRaises(TypeError, channels.register, TestClass0)
     self.assertTrue(channels.register(TestClass1))
     self.assertTrue(TestClass1.__name__ in channels._registry)
     self.assertEqual(False, channels.register(TestClass1))
    def start(self, result):
        '''
        Signals start of execution of tests.
        '''
        TestResultChannel.start(self, result)
        self._progress.start(result)

    def startTest(self, result, device):
        '''
        Signals start of execution of a test.
        '''
        TestResultChannel.startTest(self, result, device)
        self._progress.startTest(result, device)

    def stopTest(self, result, device):
        '''
        Signals stop of execution of a test.
        '''
        TestResultChannel.stopTest(self, result, device)
        self._progress.stopTest(result, device)

    def stop(self):
        '''
        Signals stop of execution of tests.
        '''
        TestResultChannel.stop(self)
        self._progress.stop()


register(ProgressChannel)
Example #8
0
 def testRegister(self):
     self.assertRaises(TypeError, channels.register, TestClass0)
     self.assertTrue(channels.register(TestClass1))
     self.assertTrue(TestClass1.__name__ in channels._registry)
     self.assertEqual(False, channels.register(TestClass1))
Example #9
0
    def stopTest(self, result, device):
        '''
        Processes a test stop execution for the summary channel.
        '''
        TestResultChannel.stopTest(self, result, device)
        if isinstance(result, TestCaseResult):
            self._counters[STATUS_NOT_COMPLETED] -= 1
            self._counters[device.status] += 1
            self._counters[_STOP_STAMP] = time.time()
        if device.cores:
            self._counters[COUNTER_CORE_DUMPS] += len(device.cores)

    def getSummary(self):
        '''
        Gets a summary of test results.
        '''
        runTime = self._counters[_STOP_STAMP] - self._counters[_START_STAMP]
        summary = {
            COUNTER_RUN_TIME: utils.runTimeToString(runTime),
            COUNTER_N_TESTS: self._counters[COUNTER_N_TESTS],
            COUNTER_TESTS_RUN: self._counters[COUNTER_TESTS_RUN],
            COUNTER_CORE_DUMPS: self._counters[COUNTER_CORE_DUMPS]
        }
        # Copy all status counters except STATUS_NO_RUN
        for status in STATUS_COUNTERS[1:]:
            summary[status] = self._counters[status]
        return summary


register(SummaryChannel)
Example #10
0
    def start(self, result):
        '''
        Signals start of execution of tests.
        '''
        TestResultChannel.start(self, result)
        self._progress.start(result)

    def startTest(self, result, device):
        '''
        Signals start of execution of a test.
        '''
        TestResultChannel.startTest(self, result, device)
        self._progress.startTest(result, device)

    def stopTest(self, result, device):
        '''
        Signals stop of execution of a test.
        '''
        TestResultChannel.stopTest(self, result, device)
        self._progress.stopTest(result, device)

    def stop(self):
        '''
        Signals stop of execution of tests.
        '''
        TestResultChannel.stop(self)
        self._progress.stop()

register(ProgressChannel)

Example #11
0
        children = element.find("children")
        for child in list(children):
            if child.tag == "case":
                self._readCaseElement(child, result)
            elif child.tag == "suite":
                self._readSuiteElement(child, result)
            else:
                raise XmlInvalidTagError(element.tag, child.tag)
        return result

    def read(self, file):
        '''
        Reads the XML file with test results.
        '''
        channels.TestResultFileChannel.read(self, file)
        fd = open(self.filePath())
        try:
            self._root = etree.ElementTree(file=fd).getroot()
            if self._root.tag != ROOT_ELEMENT:
                raise XmlInvalidTagError(self._root.tag)
            container = testresult.TestResultContainer()
            for suite in self._root.findall("suite"):
                container.children.append(self._readSuiteElement(suite, None))
            return container
        finally:
            self._root = None
            fd.close()

channels.register(XmlChannel)

## in the file CONTRIBUTION_AGREEMENT.pdf or see http://tadek.comarch.com     ##
## or write to [email protected]                                     ##
##                                                                            ##
################################################################################

from tadek.engine import channels
from tadek.engine.channels import TestResultChannel


class TestClass01(TestResultChannel):
    def __init__(self, name, **params):
        self.name = name
        self.params = params


channels.register(TestClass01)


class TestClass11(TestResultChannel):
    def __init__(self, name, **params):
        self.name = name
        self.params = params


channels.register(TestClass11)


class TestClass02(object):
    def __init__(self, name, **params):
        self.name = name
        self.params = params