11# ducktools-pythonfinder
22# MIT License
3- #
3+ #
44# Copyright (c) 2025 David C Ellis
5- #
5+ #
66# Permission is hereby granted, free of charge, to any person obtaining a copy
77# of this software and associated documentation files (the "Software"), to deal
88# in the Software without restriction, including without limitation the rights
99# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010# copies of the Software, and to permit persons to whom the Software is
1111# furnished to do so, subject to the following conditions:
12- #
12+ #
1313# The above copyright notice and this permission notice shall be included in all
1414# copies or substantial portions of the Software.
15- #
15+ #
1616# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222# SOFTWARE.
23+ import re
24+ import sys
2325import os .path
2426from types import SimpleNamespace
2527from unittest .mock import patch
2830
2931from ducktools .pythonfinder .shared import DetailFinder , PythonInstall
3032
31- fake_python_path = "/path/to/python"
32- example_json = """
33- {
34- "version": [3, 13, 2, "final", 0],
35- "executable": "/path/to/python",
36- "architecture": "64bit",
37- "implementation": "cpython",
38- "metadata": {"freethreaded": false}
39- }
33+ fake_python_path = "/path/to/python" if sys .platform != "win32" else r"X:\path\to\python"
34+ json_python_path = re .escape (fake_python_path )
35+ example_json = f"""
36+ {{
37+ "version": [3, 13, 2, "final", 0],
38+ "executable": "{ json_python_path } ",
39+ "architecture": "64bit",
40+ "implementation": "cpython",
41+ "metadata": {{"freethreaded": false}}
42+ }}
4043""" .strip ()
4144
4245example_install = PythonInstall (
@@ -160,7 +163,7 @@ def test_clear_invalid_runtimes(run_mock, stat_mock, temp_finder):
160163 with temp_finder , patch ("os.path.exists" ) as exists_patch :
161164 exists_patch .return_value = True
162165 temp_finder .clear_invalid_runtimes ()
163-
166+
164167 save_mock .assert_not_called ()
165168 assert os .path .abspath (fake_python_path ) in temp_finder .raw_cache
166169
@@ -224,4 +227,4 @@ def test_changed_stat_invalidates(run_mock, temp_finder):
224227 details = temp_finder .get_install_details (fake_python_path )
225228
226229 assert temp_finder .raw_cache [fake_abspath ]["mtime" ] == 1739886572
227- querymock .assert_called ()
230+ querymock .assert_called ()
0 commit comments