Beispiel #1
0
 def testMultipleChannelsLog(self):
     device = commons.FakeDevice()
     channels = []
     for x in xrange(2):
         channel = commons.DummyChannel("Test_%d" % x, True)
         testresult.channels.scenario.append(channel)
         channels.append(channel)
     result = TestResult()
     result.start(None)
     caseResult = commons.DummyTestResult()
     caseResult.message = messageStart = "testStart"
     result.startTest(caseResult, device)
     caseResult.message = messageStop = "testStop"
     result.stopTest(caseResult, device)
     for channel in channels:
         self.assertEqual([messageStart, messageStop], channel.testBuffer)
 def testMultipleChannelsLog(self):
     device = commons.FakeDevice()
     channels = []
     for x in xrange(2):
         channel = commons.DummyChannel("Test_%d" % x, True)
         testresult.channels.scenario.append(channel)
         channels.append(channel)
     result = TestResult()
     result.start(None)
     caseResult = commons.DummyTestResult()
     caseResult.message = messageStart = "testStart"
     result.startTest(caseResult, device)
     caseResult.message = messageStop = "testStop"
     result.stopTest(caseResult, device)
     for channel in channels:
         self.assertEqual([messageStart, messageStop], channel.testBuffer)
Beispiel #3
0
    def get(self, cls=None, name=None):
        '''
        Gets a list of channels used by the test result. If cls is provided then
        returns only channels of the given class.

        :param cls: A class of returned channels or None
        :type cls: TestResultChannel
        :param name: A name of a channel or None
        :type name: str
        :return: A list of channels
        :rtype: list
        '''
        channels = []
        for channel in self._channels:
            if ((not cls or isinstance(channel, cls)) and
                    (not name or channel.name == name)):
                channels.append(channel)
        return channels
Beispiel #4
0
 def testThreadSafety(self):
     channels = []
     threads = []
     for x in xrange(2):
         channel = commons.DummyConcurentChannel("Test_%d" % x, True)
         testresult.channels.scenario.append(channel)
         channels.append(channel)
     testRes = TestResult()
     for x in xrange(4):
         thread = OutputThread(testRes, TestCaseResult())
         thread.start()
         threads.append(thread)
     for thread in threads:
         thread.join()
     for channel in channels:
         self.assertTrue(channel.testBuffer)
         self.assertTrue(channel.testBuffer == sorted(channel.testBuffer))
         self.assertEqual(len(channel.testBuffer),
                                             len(set(channel.testBuffer)))
 def testThreadSafety(self):
     channels = []
     threads = []
     for x in xrange(2):
         channel = commons.DummyConcurentChannel("Test_%d" % x, True)
         testresult.channels.scenario.append(channel)
         channels.append(channel)
     testRes = TestResult()
     for x in xrange(4):
         thread = OutputThread(testRes, TestCaseResult())
         thread.start()
         threads.append(thread)
     for thread in threads:
         thread.join()
     for channel in channels:
         self.assertTrue(channel.testBuffer)
         self.assertTrue(channel.testBuffer == sorted(channel.testBuffer))
         self.assertEqual(len(channel.testBuffer),
                          len(set(channel.testBuffer)))