def test_failing_load_test(self): h = Host() orig_wd = h.getcwd() tmpdir = None try: tmpdir = h.mkdtemp() h.chdir(tmpdir) h.write_text_file( 'load_test.py', d("""\ import unittest def load_tests(_, _2, _3): assert False """)) test_set = TestSet(MockArgs()) test_set.parallel_tests = [TestInput('load_test.BaseTest.test_x')] r = Runner() r.args.jobs = 1 ret, _, trace = r.run(test_set) self.assertEqual(ret, 1) self.assertIn('BaseTest', trace['traceEvents'][0]['args']['err']) finally: h.chdir(orig_wd) if tmpdir: h.rmtree(tmpdir)
def test_missing_name(self): test_set = TestSet(MockArgs()) test_set.parallel_tests = [TestInput('nonexistent test')] r = Runner() r.args.jobs = 1 ret, _, _ = r.run(test_set) self.assertEqual(ret, 1)
def test_failing_load_test(self): h = Host() orig_wd = h.getcwd() tmpdir = None try: tmpdir = h.mkdtemp() h.chdir(tmpdir) h.write_text_file('load_test.py', d("""\ import unittest def load_tests(_, _2, _3): assert False """)) test_set = TestSet() test_set.parallel_tests = [TestInput('load_test.BaseTest.test_x')] r = Runner() r.args.jobs = 1 ret, _, trace = r.run(test_set) self.assertEqual(ret, 1) self.assertIn('Failed to load "load_test.BaseTest.test_x" in ' 'run_one_test', trace['traceEvents'][0]['args']['err']) finally: h.chdir(orig_wd) if tmpdir: h.rmtree(tmpdir)
def _PrefixDoesNotMatch(self, runner): test_set = TestSet(runner.args.test_name_prefix) with self.assertRaises(AssertionError) as context: runner.default_classifier(test_set, MockTestCase('test_pass')) self.assertIn( 'The test prefix passed at the command line does not match the prefix ' 'of all the tests generated', str(context.exception))
def _PrefixDoesMatch(runner): test_set = TestSet(runner.args.test_name_prefix) runner.default_classifier(test_set, MockTestCase('test_pass')) return test_set