|
| 1 | +import sys |
| 2 | +import os |
| 3 | +import platform |
| 4 | + |
| 5 | +sys.path.insert(1, os.path.join(sys.path[0], "../../")) |
| 6 | +import rips |
| 7 | + |
| 8 | +import dataroot |
| 9 | + |
| 10 | +import pytest |
| 11 | + |
| 12 | +pytestmark = pytest.mark.skipif( |
| 13 | + platform.system() != "Windows", reason="Windows-specific path test" |
| 14 | +) |
| 15 | + |
| 16 | + |
| 17 | +def test_import_well_paths_with_backslashes(rips_instance, initialize_test): |
| 18 | + """Test that Windows-style paths with backslashes are correctly handled. |
| 19 | +
|
| 20 | + This test verifies the fix for issue #13435 where backslashes in Windows paths |
| 21 | + were incorrectly interpreted as escape characters when passed from Python to |
| 22 | + ResInsight via gRPC. |
| 23 | + """ |
| 24 | + case_root_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC" |
| 25 | + case_path = case_root_path + "/TEST10K_FLT_LGR_NNC.EGRID" |
| 26 | + case = rips_instance.project.load_case(path=case_path) |
| 27 | + assert len(case.grids()) == 2 |
| 28 | + |
| 29 | + # Build paths using forward slashes first, then convert to Windows-style backslashes |
| 30 | + well_path_a = os.path.abspath( |
| 31 | + os.path.join(case_root_path, "wellpath_a.dev") |
| 32 | + ).replace("/", "\\") |
| 33 | + well_path_b = os.path.abspath( |
| 34 | + os.path.join(case_root_path, "wellpath_b.dev") |
| 35 | + ).replace("/", "\\") |
| 36 | + |
| 37 | + # The paths now contain backslashes (e.g., "C:\path\to\wellpath_a.dev") |
| 38 | + # This tests the fix for issue #13435 where backslashes were incorrectly |
| 39 | + # interpreted as escape characters |
| 40 | + well_path_files = [well_path_a, well_path_b] |
| 41 | + |
| 42 | + well_path_names = rips_instance.project.import_well_paths(well_path_files) |
| 43 | + assert len(well_path_names) == 2 |
| 44 | + wells = rips_instance.project.well_paths() |
| 45 | + assert len(wells) == 2 |
| 46 | + assert wells[0].name == "Well Path A" |
| 47 | + assert wells[1].name == "Well Path B" |
0 commit comments