Beispiel #1
0
    def assertOutput(self, template, kind, kwargs=None):
        """Assert the expected output from a run for a given test.

        :param template: A string where common strings have been replaced by a
            keyword so we don't run into pep8 warnings for long lines.

        :param kind: A string used to select the kind of test.

        :param kwargs: A dict with more keywords for the template. This allows
            some tests to add more keywords when they are test specific.
        """
        test = tests.get_case(kind)
        # Get subunit output (what subprocess produce)
        stream = StringIO()
        res = subunit.TestProtocolClient(stream)
        test.run(res)
        # Inject it again (what controlling process consumes)
        receiver = subunit.ProtocolTestCase(StringIO(stream.getvalue()))
        out = StringIO()
        res = junitxml.JUnitXmlResult(out)
        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        res._now = lambda: 0.0
        res._duration = lambda f: 0.0
        expected = tests.expand_template_for_test(template, test, kwargs)
        res.startTestRun()
        receiver.run(res)
        # due to the nature of JUnit XML output, nothing will be written to
        # the stream until stopTestRun() is called.
        res.stopTestRun()
        self.assertEquals(expected, out.getvalue())
    def assertOutput(self, template, kind, kwargs=None):
        """Assert the expected output from a run for a given test.

        :param template: A string where common strings have been replaced by a
            keyword so we don't run into pep8 warnings for long lines.

        :param kind: A string used to select the kind of test.

        :param kwargs: A dict with more keywords for the template. This allows
            some tests to add more keywords when they are test specific.
        """
        test = tests.get_case(kind)
        # Get subunit output (what subprocess produce)
        stream = StringIO()
        res = subunit.TestProtocolClient(stream)
        test.run(res)
        # Inject it again (what controlling process consumes)
        receiver = subunit.ProtocolTestCase(StringIO(stream.getvalue()))
        out = StringIO()
        res = junitxml.JUnitXmlResult(out)
        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        res._now = lambda: 0.0
        res._duration = lambda f: 0.0
        expected = tests.expand_template_for_test(template, test, kwargs)
        res.startTestRun()
        receiver.run(res)
        # due to the nature of JUnit XML output, nothing will be written to
        # the stream until stopTestRun() is called.
        res.stopTestRun()
        self.assertEquals(expected, out.getvalue())
Beispiel #3
0
 def test_skip_reason(self):
     res = self.run_test_concurrently(tests.get_case('skip_reason'), True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     reasons = res.skip_reasons
     self.assertEqual(1, len(reasons.keys()))
     reason, skipped = reasons.items()[0]
     self.assertEqual('Because', reason)
     self.assertEqual(1, len(skipped))
     self.assertEqual('sst.tests.Test.test_skip_reason', skipped[0].id())
 def test_skip_reason(self):
     res = self.run_test_concurrently(tests.get_case('skip_reason'), True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     reasons = res.skip_reasons
     self.assertEqual(1, len(reasons.keys()))
     reason, skipped = reasons.items()[0]
     self.assertEqual('Because', reason)
     self.assertEqual(1, len(skipped))
     self.assertEqual('sst.tests.Test.test_skip_reason', skipped[0].id())
Beispiel #5
0
    def assertOutput(self, expected, kind):
        test = tests.get_case(kind)
        out = StringIO()
        res = results.TextTestResult(out)

        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        def zero(atime):
            return 0.0
        res._delta_to_float = zero
        test.run(res)
        self.assertEquals(expected, res.stream.getvalue())
    def assertOutput(self, expected, kind):
        test = tests.get_case(kind)
        out = StringIO()
        res = results.TextTestResult(out)

        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        def zero(atime):
            return 0.0

        res._delta_to_float = zero
        test.run(res)
        self.assertEquals(expected, res.stream.getvalue())
    def assertSubunitOutput(self, template, kind, kwargs=None):
        """Assert the expected output from a subunit run for a given test.

        :param template: A string where common strings have been replaced by a
            keyword so we don't run into pep8 warnings for long lines.

        :param kind: A string used to select the kind of test.

        :param kwargs: A dict with more keywords for the template. This allows
            some tests to add more keywords when they are test specific.
        """
        if kwargs is None:
            kwargs = dict()
        test = tests.get_case(kind)
        res, stream = self.run_with_subunit(test)
        expected = tests.expand_template_for_test(template, test, kwargs)
        self.assertEqual(expected, stream.getvalue())
Beispiel #8
0
    def assertSubunitOutput(self, template, kind, kwargs=None):
        """Assert the expected output from a subunit run for a given test.

        :param template: A string where common strings have been replaced by a
            keyword so we don't run into pep8 warnings for long lines.

        :param kind: A string used to select the kind of test.

        :param kwargs: A dict with more keywords for the template. This allows
            some tests to add more keywords when they are test specific.
        """
        if kwargs is None:
            kwargs = dict()
        test = tests.get_case(kind)
        res, stream = self.run_with_subunit(test)
        expected = tests.expand_template_for_test(template, test, kwargs)
        self.assertEqual(expected, stream.getvalue())
Beispiel #9
0
    def assertOutput(self, expected, kind):
        test = tests.get_case(kind)
        # Get subunit output (what subprocess produce)
        stream = StringIO()
        res = subunit.TestProtocolClient(stream)
        test.run(res)
        # Inject it again (what controlling process consumes)
        receiver = subunit.ProtocolTestCase(StringIO(stream.getvalue()))
        out = StringIO()
        text_result = results.TextTestResult(out, verbosity=0)

        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        def zero(atime):
            return 0.0
        text_result._delta_to_float = zero
        receiver.run(text_result)
        self.assertEquals(expected, out.getvalue())
    def assertOutput(self, expected, kind):
        test = tests.get_case(kind)
        # Get subunit output (what subprocess produce)
        stream = StringIO()
        res = subunit.TestProtocolClient(stream)
        test.run(res)
        # Inject it again (what controlling process consumes)
        receiver = subunit.ProtocolTestCase(StringIO(stream.getvalue()))
        out = StringIO()
        text_result = results.TextTestResult(out, verbosity=0)

        # We don't care about timing here so we always return 0 which
        # simplifies matching the expected result
        def zero(atime):
            return 0.0

        text_result._delta_to_float = zero
        receiver.run(text_result)
        self.assertEquals(expected, out.getvalue())
Beispiel #11
0
 def test_pass(self):
     res = self.run_test_concurrently(tests.get_case('pass'), True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
 def test_error(self):
     res = self.run_test_concurrently(tests.get_case('error'), False)
     self.assertEqual(1, len(res.errors))
     self.assertEqual(0, len(res.failures))
 def test_pass(self):
     res = self.run_test_concurrently(tests.get_case('pass'), True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
 def setUp(self):
     super(PartitionTestCase, self).setUp()
     self.suite = unittest.TestSuite()
     self.suite.addTests([tests.get_case('pass') for i in range(8)])
Beispiel #15
0
 def test_unexpected_success(self):
     res = self.run_test_concurrently(tests.get_case('unexpected_success'),
                                      False)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     self.assertEqual(1, len(res.unexpectedSuccesses))
Beispiel #16
0
 def test_expected_failure(self):
     res = self.run_test_concurrently(tests.get_case('expected_failure'),
                                      True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     self.assertEqual(1, len(res.expectedFailures))
 def test_expected_failure(self):
     res = self.run_test_concurrently(tests.get_case('expected_failure'),
                                      True)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     self.assertEqual(1, len(res.expectedFailures))
Beispiel #18
0
 def setUp(self):
     super(PartitionTestCase, self).setUp()
     self.suite = unittest.TestSuite()
     self.suite.addTests([tests.get_case('pass') for i in range(8)])
 def test_unexpected_success(self):
     res = self.run_test_concurrently(tests.get_case('unexpected_success'),
                                      False)
     self.assertEqual(0, len(res.errors))
     self.assertEqual(0, len(res.failures))
     self.assertEqual(1, len(res.unexpectedSuccesses))
Beispiel #20
0
 def test_error(self):
     res = self.run_test_concurrently(tests.get_case('error'), False)
     self.assertEqual(1, len(res.errors))
     self.assertEqual(0, len(res.failures))