MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_source_reference

Function test_source_reference

tests_python/test_convert_utilities.py:133–170  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

131
132
133def test_source_reference(tmpdir):
134 import pydevd_file_utils
135
136 pydevd_file_utils.set_ide_os("WINDOWS")
137 if IS_WINDOWS:
138 # Client and server are on windows.
139 pydevd_file_utils.setup_client_server_paths([("c:\\foo", "c:\\bar")])
140
141 assert pydevd_file_utils.map_file_to_client("c:\\bar\\my") == ("c:\\foo\\my", True)
142 assert pydevd_file_utils.get_client_filename_source_reference("c:\\foo\\my") == 0
143
144 assert pydevd_file_utils.map_file_to_client("c:\\another\\my") == ("c:\\another\\my", False)
145 source_reference = pydevd_file_utils.get_client_filename_source_reference("c:\\another\\my")
146 assert source_reference != 0
147 assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == "c:\\another\\my"
148
149 else:
150 # Client on windows and server on unix
151 pydevd_file_utils.set_ide_os("WINDOWS")
152
153 pydevd_file_utils.setup_client_server_paths([("C:\\foo", "/bar")])
154
155 assert pydevd_file_utils.map_file_to_client("/bar/my") == ("C:\\foo\\my", True)
156 assert pydevd_file_utils.get_client_filename_source_reference("C:\\foo\\my") == 0
157
158 assert pydevd_file_utils.map_file_to_client("/another/my") == ("\\another\\my", False)
159 source_reference = pydevd_file_utils.get_client_filename_source_reference("\\another\\my")
160 assert source_reference != 0
161 assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == "/another/my"
162
163 # Allow relative paths in the server path
164 pydevd_file_utils.setup_client_server_paths([("C:\\foo", "./bar")])
165 root = os.getcwd()
166 server_path = os.path.join(root, "bar/my")
167
168 assert pydevd_file_utils.map_file_to_client(server_path) == ("C:\\foo\\my", True)
169 assert pydevd_file_utils.get_client_filename_source_reference("C:\\foo\\my") == 0
170 assert pydevd_file_utils.map_file_to_server("c:\\foo\\my") == server_path
171
172
173@pytest.mark.skipif(sys.platform != "win32", reason="Windows-only test.")

Callers

nothing calls this directly

Calls 2

set_ide_osMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected