def test_runner_09(mocker, tmp_path): """test Runner.run() adding includes to testcase""" server = mocker.Mock(spec=Sapphire) target = mocker.Mock(spec=Target) target.detect_failure.return_value = target.RESULT_NONE runner = Runner(server, target) # create test files inc_path1 = (tmp_path / "include") inc_path1.mkdir() inc1 = (inc_path1 / "inc_file.bin") inc1.write_bytes(b"a") (inc_path1 / "nested").mkdir() inc2 = (inc_path1 / "nested" / "nested_inc.bin") inc2.write_bytes(b"a") inc_path2 = (tmp_path / "include2") inc_path2.mkdir() inc3 = (inc_path2 / "inc_file3.txt") inc3.write_bytes(b"a") # build server map smap = ServerMap() smap.set_include("/", str(inc_path1)) smap.set_include("/test", str(inc_path2)) serv_files = ["a.b", str(inc1), str(inc2), str(inc3)] server.serve_testcase.return_value = (SERVED_ALL, serv_files) with TestCase("a.b", "x", "x") as tcase: runner.run([], smap, tcase) assert runner.result == runner.COMPLETE assert "inc_file.bin" in tcase._existing_paths assert pathjoin("nested", "nested_inc.bin") in tcase._existing_paths assert pathjoin("test", "inc_file3.txt") in tcase._existing_paths
def test_runner_10(mocker, tmp_path): """test Runner.run() adding includes to testcase""" server = mocker.Mock(spec_set=Sapphire) target = mocker.Mock(spec_set=Target) target.check_result.return_value = Result.NONE runner = Runner(server, target, relaunch=10) # create test files inc_path1 = tmp_path / "include" inc_path1.mkdir() inc1 = inc_path1 / "inc_file.bin" inc1.write_bytes(b"a") (inc_path1 / "nested").mkdir() inc2 = inc_path1 / "nested" / "nested_inc.bin" inc2.write_bytes(b"a") inc_path2 = tmp_path / "include2" inc_path2.mkdir() inc3 = inc_path2 / "inc_file3.txt" inc3.write_bytes(b"a") # build server map smap = ServerMap() smap.set_include("/", str(inc_path1)) smap.set_include("/test", str(inc_path2)) serv_files = ["a.b", str(inc1), str(inc2), str(inc3)] server.serve_path.return_value = (Served.ALL, serv_files) with TestCase("a.b", "x", "x") as tcase: result = runner.run([], smap, tcase) assert result.attempted assert result.status == Result.NONE assert "inc_file.bin" in tcase.contents assert "nested/nested_inc.bin" in tcase.contents assert "test/inc_file3.txt" in tcase.contents