Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added test_unmanaged_py_shebang
  • Loading branch information
Jesse205 committed Mar 20, 2026
commit 6321223543eb5b188be777d1701779b3a19ced79
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ def __init__(self, global_dir, installs=[]):
self.shebang_can_run_anything_silently = False
self.scratch = {}

def get_installs(self, *, include_unmanaged=True, set_default=True):
return self.installs
def get_installs(self, *, include_unmanaged=False, set_default=True):
if include_unmanaged:
return self.installs
return [i for i in self.installs if not i.get("unmanaged", 0)]

def get_install_to_run(self, tag, *, windowed=False):
if windowed:
Expand All @@ -171,7 +173,7 @@ def get_install_to_run(self, tag, *, windowed=False):

company, _, tag = tag.replace("/", "\\").rpartition("\\")
return [i for i in self.installs
if i["tag"] == tag and (not company or i["company"] == company)][0]
if (not tag or i["tag"] == tag) and (not company or i["company"] == company)][0]


@pytest.fixture
Expand Down
19 changes: 19 additions & 0 deletions tests/test_scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ def t(n):
assert t("pythonw1.0")["executable"].match("pythonw.exe")


def test_unmanaged_py_shebang(fake_config, tmp_path):
inst = _fake_install("1.0", company="PythonCore", prefix=PurePath("C:\\TestRoot"))
inst["unmanaged"] = 1
inst["run-for"] = [
dict(name="python.exe", target=".\\python.exe"),
dict(name="pythonw.exe", target=".\\pythonw.exe", windowed=1),
]
fake_config.installs[:] = [inst]

def t(n):
return _find_shebang_command(fake_config, n, windowed=False)

# Finds the install's default executable
assert t("python")["executable"].match("test-binary-1.0.exe")
assert t("python1.0")["executable"].match("test-binary-1.0.exe")
# Finds the install's run-for executable with windowed=1
assert t("pythonw")["executable"].match("pythonw.exe")
assert t("pythonw1.0")["executable"].match("pythonw.exe")


@pytest.mark.parametrize("script, expect", [
("# not a coding comment", None),
Expand Down
Loading