Skip to content

Commit 747e01b

Browse files
committed
Added test_unmanaged_py_shebang
1 parent 621dcb0 commit 747e01b

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

tests/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from manage.tagutils import CompanyTag
23
import pytest
34
import random
45
import re
@@ -158,8 +159,10 @@ def __init__(self, global_dir, installs=[]):
158159
self.shebang_can_run_anything_silently = False
159160
self.scratch = {}
160161

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

164167
def get_install_to_run(self, tag, *, windowed=False):
165168
if windowed:
@@ -171,7 +174,7 @@ def get_install_to_run(self, tag, *, windowed=False):
171174

172175
company, _, tag = tag.replace("/", "\\").rpartition("\\")
173176
return [i for i in self.installs
174-
if i["tag"] == tag and (not company or i["company"] == company)][0]
177+
if (not tag or i["tag"] == tag) and (not company or i["company"] == company)][0]
175178

176179

177180
@pytest.fixture

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)