Ejemplo n.º 1
0
    def test_parse_results_file(self):
        result = subunit_v2.parse_results_file(self.fake_stream)

        self.assertEqual({"skipped": 1,
                          "success": 2,
                          "time": "5.007",
                          "failures": 3,
                          "expected_failures": 0,
                          "tests": 7,
                          "unexpected_success": 1}, result.total)
        self.assertEqual(len(result.tests), result.total["tests"])

        skipped_tests = result.filter_tests("skip")
        skipped_test = "test_foo.SimpleTestCase.test_skip_something"

        self.assertEqual(result.total["skipped"], len(skipped_tests))
        self.assertSequenceEqual([skipped_test], skipped_tests.keys())
        self.assertEqual(
            {"status": "skip", "reason": "This should be skipped.",
             "time": "0.000", "name": skipped_test},
            skipped_tests[skipped_test])

        failed_tests = result.filter_tests("fail")
        failed_test = "test_foo.SimpleTestCaseWithBrokenSetup.test_something"

        self.assertEqual(result.total["failures"], len(failed_tests))
        self.assertIn(failed_test, failed_tests)
        trace = """Traceback (most recent call last):
  File "test_foo.py", line 34, in setUp
    raise RuntimeError("broken setUp method")
RuntimeError: broken setUp method
"""
        self.assertEqual({"status": "fail", "traceback": trace,
                          "time": "0.000", "name": failed_test},
                         failed_tests[failed_test])
Ejemplo n.º 2
0
 def parse_results(self, log_file=None):
     """Parse subunit raw log file."""
     log_file_raw = log_file or self.log_file_raw
     if os.path.isfile(log_file_raw):
         return subunit_v2.parse_results_file(log_file_raw)
     else:
         LOG.error("JSON-log file not found.")
         return None
Ejemplo n.º 3
0
 def parse_results(self, log_file=None):
     """Parse subunit raw log file."""
     log_file_raw = log_file or self.log_file_raw
     if os.path.isfile(log_file_raw):
         return subunit_v2.parse_results_file(log_file_raw)
     else:
         LOG.error("JSON-log file not found.")
         return None
Ejemplo n.º 4
0
    def test_parse_results_file_with_expected_failures(self):
        test_1 = "test_foo.SimpleTestCase.test_something_that_fails"
        test_2 = "test_foo.SimpleTestCase.test_something_that_passes"
        expected_failures = {
            test_1: "Some details about why this test fails",
            test_2: None
        }

        result = subunit_v2.parse_results_file(self.fake_stream,
                                               expected_failures)
        tests = result.tests

        self.assertEqual("xfail", tests[test_1]["status"])
        self.assertEqual("Some details about why this test fails",
                         tests[test_1]["reason"])
        self.assertEqual("uxsuccess", tests[test_2]["status"])
Ejemplo n.º 5
0
    def test_parse_results_file(self):
        result = subunit_v2.parse_results_file(self.fake_stream)

        self.assertEqual(
            {
                "skipped": 1,
                "success": 2,
                "time": "5.00732",
                "failures": 3,
                "expected_failures": 0,
                "tests": 7,
                "unexpected_success": 1
            }, result.total)
        self.assertEqual(len(result.tests), result.total["tests"])

        skipped_tests = result.filter_tests("skip")
        skipped_test = "test_foo.SimpleTestCase.test_skip_something"

        self.assertEqual(result.total["skipped"], len(skipped_tests))
        self.assertSequenceEqual([skipped_test], skipped_tests.keys())
        self.assertEqual(
            {
                "status": "skip",
                "reason": "This should be skipped.",
                "time": "0.00007",
                "name": skipped_test
            }, skipped_tests[skipped_test])

        failed_tests = result.filter_tests("fail")
        failed_test = "test_foo.SimpleTestCaseWithBrokenSetup.test_something"

        self.assertEqual(result.total["failures"], len(failed_tests))
        self.assertIn(failed_test, failed_tests)
        trace = """Traceback (most recent call last):
  File "test_foo.py", line 34, in setUp
    raise RuntimeError("broken setUp method")
RuntimeError: broken setUp method
"""
        self.assertEqual(
            {
                "status": "fail",
                "traceback": trace,
                "time": "0.00005",
                "name": failed_test
            }, failed_tests[failed_test])