def plan(tmpdir): """Yield an interactive testplan.""" plan = testplan.TestplanMock( name=six.ensure_str("InteractiveAPITest"), interactive_port=0, interactive_block=False, exporters=[XMLExporter(xml_dir=tmpdir / "xml_exporter")], ) logfile = tmpdir / "attached_log.txt" logfile.write_text( "This text will be written into the attached file.", encoding="utf8", ) plan.add( multitest.MultiTest( name=six.ensure_str("ExampleMTest"), suites=[ExampleSuite(str(logfile))], ) ) plan.run() timing.wait( lambda: plan.interactive.http_handler_info is not None, 300, raise_on_timeout=True, ) yield plan plan.abort()
def plan(tmpdir): """Yield an interactive testplan.""" with mock.patch("testplan.runnable.interactive.reloader.ModuleReloader" ) as MockReloader: MockReloader.return_value = None plan = testplan.TestplanMock( name="InteractiveAPITest", interactive_port=0, interactive_block=False, exporters=[XMLExporter(xml_dir=str(tmpdir / "xml_exporter"))], ) logfile = tmpdir / "attached_log.txt" logfile.write_text( "This text will be written into the attached file.", encoding="utf-8", ) plan.add( multitest.MultiTest( name="ExampleMTest", suites=[ExampleSuite(str(logfile))], )) plan.run() timing.wait( lambda: plan.interactive.http_handler_info is not None, 300, raise_on_timeout=True, ) yield plan plan.abort()
def _factory(pattern=None): plan = testplan.TestplanMock( name="Logging TestPlan", test_filter=Pattern(pattern) if pattern else Filter(), ) plan.add(multitest.MultiTest(name="Logging Test", suites=suites)) return plan
def attachment_plan(tmpdir): attachment_path = str(tmpdir.join("attachment.txt")) with open(attachment_path, "w") as f: f.write("testplan\n" * 100) plan = testplan.TestplanMock(name="AttachmentPlan") plan.add( multitest.MultiTest(name="AttachmentTest", suites=[Suite1(attachment_path)])) return plan
def multi_attachments_plan(tmpdir): attachment_paths = [ str(tmpdir.join("attachment{}.txt".format(i))) for i in range(2) ] # Write different content to each file to ensure they get a unique hash. for i, attachment_path in enumerate(attachment_paths): with open(attachment_path, "w") as f: f.write("testplan{}\n".format(i) * 100) plan = testplan.TestplanMock(name="AttachmentPlan") plan.add( multitest.MultiTest( name="AttachmentTest", suites=[Suite1(attachment_paths[0]), Suite2(attachment_paths[1])], )) return plan
def multi_attachments_plan(tmpdir): attachment_paths = [ str(tmpdir.mkdir(f"{i}").join("attachment.txt")) for i in range(2) ] # Write different content to each file to ensure they get a unique hash. for i, attachment_path in enumerate(attachment_paths): with open(attachment_path, "w") as f: f.write(f"testplan{i}\n") plan = testplan.TestplanMock(name="AttachmentPlan") plan.add( multitest.MultiTest( name="AttachmentTest", suites=[Suite1(attachment_paths)], )) return plan