Skip to content

Commit b57b729

Browse files
committed
Added test_unmanaged_py_shebang
1 parent 621dcb0 commit b57b729

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

tests/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ def __init__(self, global_dir, installs=[]):
158158
self.shebang_can_run_anything_silently = False
159159
self.scratch = {}
160160

161-
def get_installs(self, *, include_unmanaged=True, set_default=True):
162-
return self.installs
161+
def get_installs(self, *, include_unmanaged=False, set_default=True):
162+
if include_unmanaged:
163+
return self.installs
164+
return [i for i in self.installs if not i.get("unmanaged", 0)]
163165

164166
def get_install_to_run(self, tag, *, windowed=False):
165167
if windowed:

tests/test_scriptutils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@ def t(n):
157157
assert t("pythonw1.0")["executable"].match("pythonw.exe")
158158

159159

160+
def test_unmanaged_py_shebang(fake_config, tmp_path):
161+
inst = _fake_install("1.0", company="PythonCore", prefix=PurePath("C:\\TestRoot"))
162+
inst["unmanaged"] = 1
163+
inst["run-for"] = [
164+
dict(name="python.exe", target=".\\python.exe"),
165+
dict(name="pythonw.exe", target=".\\pythonw.exe", windowed=1),
166+
]
167+
fake_config.installs[:] = [inst]
168+
169+
def t(n):
170+
return _find_shebang_command(fake_config, n, windowed=False)
171+
172+
# Finds the install's default executable
173+
assert t("python")["executable"].match("test-binary-1.0.exe")
174+
assert t("python1.0")["executable"].match("test-binary-1.0.exe")
175+
# Finds the install's run-for executable with windowed=1
176+
assert t("pythonw")["executable"].match("pythonw.exe")
177+
assert t("pythonw1.0")["executable"].match("pythonw.exe")
178+
160179

161180
@pytest.mark.parametrize("script, expect", [
162181
("# not a coding comment", None),

0 commit comments

Comments
 (0)