Skip to content

Commit f1f50a0

Browse files
committed
fix: test failure
Signed-off-by: Frost Ming <[email protected]>
1 parent ebdeae8 commit f1f50a0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/cli/test_python.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import sys
23
from pathlib import Path
34

@@ -20,21 +21,21 @@ def install_file(
2021
Path(destination, "bin", "python3").touch()
2122

2223
def get_version(self):
23-
if sys.platform == "win32":
24-
return Version(self.executable.parent.name.split("@", 1)[1])
25-
else:
26-
return Version(self.executable.parent.parent.name.split("@", 1)[1])
24+
name = self.executable.parent.name if sys.platform == "win32" else self.executable.parent.parent.name
25+
if "@" not in name:
26+
return Version(platform.python_version())
27+
return Version(name.split("@", 1)[1])
2728

2829
@property
2930
def interpreter(self):
3031
return self.executable
3132

3233
@property
3334
def implementation(self):
34-
if sys.platform == "win32":
35-
return self.executable.parent.name.split("@", 1)[0]
36-
else:
37-
return self.executable.parent.parent.name.split("@", 1)[0]
35+
name = self.executable.parent.name if sys.platform == "win32" else self.executable.parent.parent.name
36+
if "@" not in name:
37+
return "cpython"
38+
return name.split("@", 1)[0]
3839

3940
mocker.patch("pbs_installer.download", return_value="python-3.10.8.tar.gz")
4041
installer = mocker.patch("pbs_installer.install_file", side_effect=install_file)
@@ -48,7 +49,7 @@ def implementation(self):
4849
def test_install_python(project, pdm, mock_install):
4950
root = Path(project.config["python.install_root"])
5051

51-
pdm(["py", "install", "[email protected]"], obj=project, strict=True)
52+
pdm(["py", "install", "[email protected]", "-v"], obj=project, strict=True)
5253
mock_install.assert_called_once()
5354
assert (root / "[email protected]").exists()
5455

0 commit comments

Comments
 (0)