(case_setup, mixed_case)
| 2335 | |
| 2336 | @pytest.mark.parametrize("mixed_case", [True, False] if sys.platform == "win32" else [False]) |
| 2337 | def test_path_translation(case_setup, mixed_case): |
| 2338 | def get_file_in_client(writer): |
| 2339 | # Instead of using: test_python/_debugger_case_path_translation.py |
| 2340 | # we'll set the breakpoints at foo/_debugger_case_path_translation.py |
| 2341 | file_in_client = os.path.dirname(os.path.dirname(writer.TEST_FILE)) |
| 2342 | return os.path.join(os.path.dirname(file_in_client), "foo", "_debugger_case_path_translation.py") |
| 2343 | |
| 2344 | def get_environ(writer): |
| 2345 | import json |
| 2346 | |
| 2347 | env = os.environ.copy() |
| 2348 | |
| 2349 | env["PYTHONIOENCODING"] = "utf-8" |
| 2350 | |
| 2351 | assert writer.TEST_FILE.endswith("_debugger_case_path_translation.py") |
| 2352 | file_in_client = get_file_in_client(writer) |
| 2353 | if mixed_case: |
| 2354 | new_file_in_client = "".join( |
| 2355 | [file_in_client[i].upper() if i % 2 == 0 else file_in_client[i].lower() for i in range(len(file_in_client))] |
| 2356 | ) |
| 2357 | assert _path_equals(file_in_client, new_file_in_client) |
| 2358 | env["PATHS_FROM_ECLIPSE_TO_PYTHON"] = json.dumps([(os.path.dirname(file_in_client), os.path.dirname(writer.TEST_FILE))]) |
| 2359 | return env |
| 2360 | |
| 2361 | with case_setup.test_file("_debugger_case_path_translation.py", get_environ=get_environ) as writer: |
| 2362 | from tests_python.debugger_unittest import CMD_LOAD_SOURCE |
| 2363 | |
| 2364 | writer.write_start_redirect() |
| 2365 | |
| 2366 | file_in_client = get_file_in_client(writer) |
| 2367 | assert "tests_python" not in file_in_client |
| 2368 | writer.write_add_breakpoint(writer.get_line_index_with_content("break here"), "call_this", filename=file_in_client) |
| 2369 | writer.write_make_initial_run() |
| 2370 | |
| 2371 | xml = writer.wait_for_message(lambda msg: 'stop_reason="111"' in msg) |
| 2372 | assert xml.thread.frame[0]["file"] == file_in_client |
| 2373 | thread_id = xml.thread["id"] |
| 2374 | |
| 2375 | # Request a file that exists |
| 2376 | files_to_match = [file_in_client] |
| 2377 | if IS_WINDOWS: |
| 2378 | files_to_match.append(file_in_client.upper()) |
| 2379 | for f in files_to_match: |
| 2380 | writer.write_load_source(f) |
| 2381 | writer.wait_for_message( |
| 2382 | lambda msg: "%s\t" % CMD_LOAD_SOURCE in msg |
| 2383 | and "def main():" in msg |
| 2384 | and "print('break here')" in msg |
| 2385 | and "print('TEST SUCEEDED!')" in msg, |
| 2386 | expect_xml=False, |
| 2387 | ) |
| 2388 | |
| 2389 | # Request a file that does not exist |
| 2390 | writer.write_load_source(file_in_client + "not_existent.py") |
| 2391 | writer.wait_for_message(lambda msg: "901\t" in msg and ("FileNotFoundError" in msg or "IOError" in msg), expect_xml=False) |
| 2392 | |
| 2393 | writer.write_run_thread(thread_id) |
| 2394 |
nothing calls this directly
no test coverage detected