def irunner(): """Set up an irunner instance for testing.""" target = runnable.TestRunner(name="TestRunner") local_runner = runners.LocalRunner() test_uids = ["test_1", "test_2", "test_3"] test_objs = [ multitest.MultiTest( name=uid, suites=[Suite()], test_filter=filtering.Filter(), test_sorter=ordering.NoopSorter(), stdout_style=defaults.STDOUT_STYLE, environment=[driver.Driver(name="mock_driver")], ) for uid in test_uids ] for test in test_objs: local_runner.add(test, test.uid()) target.resources.add(local_runner) with mock.patch("cheroot.wsgi.Server"): irunner = base.TestRunnerIHandler(target) irunner.setup() yield irunner irunner.teardown()
def test_run_all_tagged_tests(tags, num_of_suite_entries): """Test running all tests whose testcases are selected by tags.""" target = runnable.TestRunner(name="TestRunner") local_runner = LocalRunner() test_uids = ["test_1", "test_2", "test_3"] test_objs = [ multitest.MultiTest( name=uid, suites=[TaggedSuite()], test_filter=filtering.Tags({"simple": set(tags)}), test_sorter=ordering.NoopSorter(), stdout_style=defaults.STDOUT_STYLE, environment=[driver.Driver(name="mock_driver")], ) for uid in test_uids ] for test in test_objs: local_runner.add(test, test.uid()) target.resources.add(local_runner) with mock.patch("cheroot.wsgi.Server"), mock.patch( "testplan.runnable.interactive.reloader.ModuleReloader" ) as MockReloader: MockReloader.return_value = None irunner = base.TestRunnerIHandler(target) irunner.setup() irunner.run_all_tests(await_results=True) assert irunner.report.passed assert len(irunner.report.entries) == 3 for test_report in irunner.report: assert test_report.passed assert len(test_report.entries) == 1 assert len(test_report.entries[0].entries) == num_of_suite_entries assert len(test_report.entries[0].entries[-1].entries) == 3 irunner.teardown()