Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 def test_max_failures_ignored_if_unset(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.FailureTests']
     r.args.jobs = 1
     r.args.typ_max_failures = None
     r.context = True
     r.run()
Esempio n. 5
0
 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)
Esempio n. 6
0
 def test_max_failures_fail_if_equal(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.FailureTests']
     r.args.jobs = 1
     r.args.typ_max_failures = 1
     r.context = True
     with self.assertRaises(RuntimeError):
         r.run()
Esempio n. 7
0
 def test_max_failures_pass_if_under(self):
     r = Runner()
     r.args.tests = [
         'typ.tests.runner_test.ContextTests',
         'typ.tests.runner_test.FAilureTests'
     ]
     r.args.jobs = 1
     r.args.typ_max_failures = 2
     r.context = True
     r.run()
Esempio n. 8
0
 def test_context(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.ContextTests']
     r.context = {'foo': 'bar'}
     r.setup_fn = _setup_process
     r.teardown_fn = _teardown_process
     r.win_multiprocessing = WinMultiprocessing.importable
     ret, _, _ = r.run()
     self.assertEqual(ret, 0)
Esempio n. 9
0
    def call(self, argv, platform=None, win_multiprocessing=None, **kwargs):
        h = self.make_host()
        orig_wd = h.getcwd()
        tmpdir = None
        try:
            tmpdir = h.mkdtemp()
            h.chdir(tmpdir)
            h.capture_output()
            if platform is not None:
                h.platform = platform
            r = Runner(h)
            if win_multiprocessing is not None:
                r.win_multiprocessing = win_multiprocessing
            ret = r.main(argv, **kwargs)
        finally:
            out, err = h.restore_output()
            h.chdir(orig_wd)
            if tmpdir:
                h.rmtree(tmpdir)

        return ret, out, err
Esempio n. 10
0
    def call(self, argv, platform=None, win_multiprocessing=None, **kwargs):
        h = self.make_host()
        orig_wd = h.getcwd()
        tmpdir = None
        try:
            tmpdir = h.mkdtemp()
            h.chdir(tmpdir)
            h.capture_output()
            if platform is not None:
                h.platform = platform
            r = Runner(h)
            if win_multiprocessing is not None:
                r.win_multiprocessing = win_multiprocessing
            ret = r.main(argv, **kwargs)
        finally:
            out, err = h.restore_output()
            h.chdir(orig_wd)
            if tmpdir:
                h.rmtree(tmpdir)

        return ret, out, err
Esempio n. 11
0
 def test_exception_in_teardown(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.ContextTests']
     r.context = {'foo': 'bar'}
     r.setup_fn = _setup_process
     r.teardown_fn = _teardown_throws
     r.win_multiprocessing = WinMultiprocessing.importable
     ret, _, _ = r.run()
     self.assertEqual(ret, 0)
     self.assertEqual(r.final_responses[0][2].message,
                      'exception in teardown')
Esempio n. 12
0
 def test_context(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.ContextTests']
     r.context = {'foo': 'bar'}
     r.setup_fn = _setup_process
     r.teardown_fn = _teardown_process
     r.win_multiprocessing = WinMultiprocessing.importable
     ret, _, _ = r.run()
     self.assertEqual(ret, 0)
Esempio n. 13
0
 def test_exception_in_teardown(self):
     r = Runner()
     r.args.tests = ['typ.tests.runner_test.ContextTests']
     r.context = {'foo': 'bar'}
     r.setup_fn = _setup_process
     r.teardown_fn = _teardown_throws
     r.win_multiprocessing = WinMultiprocessing.importable
     ret, _, _ = r.run()
     self.assertEqual(ret, 0)
     self.assertEqual(r.final_responses[0][2].message,
                      'exception in teardown')
Esempio n. 14
0
 def test_good_default(self):
     r = Runner()
     ret = r.main([], tests=['typ.tests.runner_test.ContextTests'])
     self.assertEqual(ret, 0)
Esempio n. 15
0
 def test_bad_default(self):
     r = Runner()
     ret = r.main([], foo='bar')
     self.assertEqual(ret, 2)
Esempio n. 16
0
 def test_isolate_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(
         test_name_prefix='DontMatch', isolate_globs=['test_pas*'],
         test_filter='test_pass')
     self._PrefixDoesNotMatch(runner)
Esempio n. 17
0
 def test_isolate_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(test_name_prefix='DontMatch',
                            isolate_globs=['test_pas*'],
                            test_filter='test_pass')
     self._PrefixDoesNotMatch(runner)
Esempio n. 18
0
 def test_isolate_arg(self):
     runner = Runner()
     runner.args = MockArgs(isolate_globs=['test_pas*'], test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.isolated_tests), 1)
Esempio n. 19
0
 def test_skip_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(test_name_prefix='DontMatch',
                            skip_globs=['test_pas*'])
     self._PrefixDoesNotMatch(runner)
Esempio n. 20
0
 def test_bad_default(self):
     r = Runner()
     ret = r.main([], foo='bar')
     self.assertEqual(ret, 2)
Esempio n. 21
0
 def test_good_default(self):
     r = Runner()
     ret = r.main([], tests=['typ.tests.runner_test.ContextTests'])
     self.assertEqual(ret, 0)
Esempio n. 22
0
 def test_test_filter_arg(self):
     runner = Runner()
     runner.args = MockArgs(test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.parallel_tests), 1)
Esempio n. 23
0
 def test_test_filter_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(test_name_prefix='DontMatch')
     self._PrefixDoesNotMatch(runner)
Esempio n. 24
0
 def test_test_filter_arg(self):
     runner = Runner()
     runner.args = MockArgs(test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.parallel_tests), 1)
Esempio n. 25
0
 def test_test_filter_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(test_name_prefix='DontMatch')
     self._PrefixDoesNotMatch(runner)
Esempio n. 26
0
 def test_skip_arg(self):
     runner = Runner()
     runner.args = MockArgs(skip_globs=['test_pas*'],
                            test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.tests_to_skip), 1)
Esempio n. 27
0
 def test_skip_arg(self):
     runner = Runner()
     runner.args = MockArgs(skip_globs=['test_pas*'], test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.tests_to_skip), 1)
Esempio n. 28
0
 def test_isolate_arg(self):
     runner = Runner()
     runner.args = MockArgs(isolate_globs=['test_pas*'],
                            test_filter='test_pass')
     test_set = _PrefixDoesMatch(runner)
     self.assertEqual(len(test_set.isolated_tests), 1)
Esempio n. 29
0
 def test_skip_arg_causes_assertion(self):
     runner = Runner()
     runner.args = MockArgs(
         test_name_prefix='DontMatch', skip_globs=['test_pas*'])
     self._PrefixDoesNotMatch(runner)