def test_report_extended_test_module_name(self): """When `JSONReporter` logs the results for a test, make sure it records the module that the test method's `TestCase` is in, and not the module of the `TestCase`'s base class that defined the method. Regression test for GitHub #13. """ result = test_result.TestResult(self.extended_test_case.test_method) self.json_reporter.test_start(result.to_dict()) result.start() result.end_in_success() self.json_reporter.test_complete(result.to_dict()) assert_equal(True, self.json_reporter.report()) log_lines = ''.join(line for line in self.log_file.getvalue().splitlines() if line != 'RUN COMPLETE') result = json.loads(log_lines) assert_equal('extended', result['method']['module']) assert_equal('extended ExtendedTestCase.test_method', result['method']['full_name'])
def test_test_result_is_serializable(self): result = test_result.TestResult(self.null_test_case.test_method) json.dumps(result.to_dict()) result.start() json.dumps(result.to_dict()) result.end_in_success() json.dumps(result.to_dict())
def test_not_garbled_by_serialization(self): """Make sure that converting to JSON and back results in the same dictionary.""" result = test_result.TestResult(self.null_test_case.test_method) assert_equal(result.to_dict(), json.loads(json.dumps(result.to_dict()))) result.start() assert_equal(result.to_dict(), json.loads(json.dumps(result.to_dict()))) result.end_in_success() assert_equal(result.to_dict(), json.loads(json.dumps(result.to_dict())))
def test_fake_result_format(self): get_test(self.server, 'runner1') fake_result = self.server._fake_result('foo', 'bar', 'baz') fake_result = _replace_values_with_types(fake_result) real_result = test_result.TestResult(self.dummy_test_case.test, runner_id='foo!') real_result.start() try: print 1/0 except: import sys real_result.end_in_failure(sys.exc_info()) real_result = real_result.to_dict() real_result = _replace_values_with_types(real_result) assert_equal(fake_result, real_result)
def make_fake_result(method): result = test_result.TestResult(getattr(self.dummy_test_case, method)) result.start() result.end_in_success() return result.to_dict()