def test_parse_file_with_skipped_tests(self): test_id = "test_foo.SimpleTestCase.test_to_skip" skipped_tests = {test_id: "Some details why this test skipped"} result = subunit_v2.parse_file( self.fake_stream, skipped_tests=skipped_tests, live=True) tests = result.tests self.assertEqual("skip", tests[test_id]["status"]) self.assertEqual("Some details why this test skipped", tests[test_id]["reason"])
def test_parse_file(self): result = subunit_v2.parse_file(self.fake_stream, live=True) self.assertEqual( { "tests_count": 7, "tests_duration": "5.007", "skipped": 1, "success": 2, "failures": 3, "expected_failures": 0, "unexpected_success": 1 }, result.totals) self.assertEqual(len(result.tests), result.totals["tests_count"]) skipped_tests = result.filter_tests("skip") skipped_test = "test_foo.SimpleTestCase.test_skip_something" self.assertEqual(result.totals["skipped"], len(skipped_tests)) self.assertSequenceEqual([skipped_test], skipped_tests.keys()) self.assertEqual( { "status": "skip", "reason": "This should be skipped.", "duration": "0.000", "name": skipped_test, "tags": [], "timestamp": "2015-06-03T08:46:17+0000" }, skipped_tests[skipped_test]) failed_tests = result.filter_tests("fail") failed_test = "test_foo.SimpleTestCaseWithBrokenSetup.test_something" self.assertEqual(result.totals["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, "tags": [], "duration": "0.000", "name": failed_test, "timestamp": "2015-06-03T08:46:22+0000" }, failed_tests[failed_test])
def test_parse_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_file( self.fake_stream, expected_failures=expected_failures, live=True) 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"])
def test_parse_file(self): result = subunit_v2.parse_file(self.fake_stream, live=True) self.assertEqual({"tests_count": 7, "tests_duration": "5.007", "skipped": 1, "success": 2, "failures": 3, "expected_failures": 0, "unexpected_success": 1}, result.totals) self.assertEqual(len(result.tests), result.totals["tests_count"]) skipped_tests = result.filter_tests("skip") skipped_test = "test_foo.SimpleTestCase.test_skip_something" self.assertEqual(result.totals["skipped"], len(skipped_tests)) self.assertSequenceEqual([skipped_test], skipped_tests.keys()) self.assertEqual( {"status": "skip", "reason": "This should be skipped.", "duration": "0.000", "name": skipped_test, "tags": [], "timestamp": "2015-06-03T08:46:17+0000"}, skipped_tests[skipped_test]) failed_tests = result.filter_tests("fail") failed_test = "test_foo.SimpleTestCaseWithBrokenSetup.test_something" self.assertEqual(result.totals["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, "tags": [], "duration": "0.000", "name": failed_test, "timestamp": "2015-06-03T08:46:22+0000"}, failed_tests[failed_test])