-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathwheel_install_test.py
More file actions
83 lines (72 loc) · 2.37 KB
/
Copy pathwheel_install_test.py
File metadata and controls
83 lines (72 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
import subprocess
import sys
import tempfile
import unittest
import venv
from pathlib import Path
class WheelInstallTest(unittest.TestCase):
def setUp(self):
self.wheel_path = Path(sys.argv[1]).resolve()
self.temp_dir = tempfile.TemporaryDirectory()
self.addCleanup(self.temp_dir.cleanup)
self.temp_path = Path(self.temp_dir.name)
self.venv_path = self.temp_path / "venv"
venv.EnvBuilder(with_pip=True).create(self.venv_path)
self.python = self.venv_path / "bin" / "python"
self.env = os.environ.copy()
for variable in ("PYTHONHOME", "PYTHONPATH", "PYTHONUSERBASE"):
self.env.pop(variable, None)
self.env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"
self.env["PYTHONNOUSERSITE"] = "1"
def run_command(self, *args):
result = subprocess.run(
args,
cwd=self.temp_path,
env=self.env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)
self.assertEqual(0, result.returncode, msg=result.stdout)
return result.stdout
def test_install_resolves_requests_and_starts_http_command(self):
self.run_command(
self.python,
"-I",
"-c",
"import importlib.util; "
"assert importlib.util.find_spec('requests') is None",
)
self.run_command(
self.python,
"-m",
"pip",
"install",
"--no-input",
self.wheel_path,
)
self.run_command(self.python, "-m", "pip", "check")
self.run_command(
self.python,
"-I",
"-c",
"from importlib.metadata import version; "
"assert version('requests') == '2.32.5'; "
"import certifi, charset_normalizer, idna, requests, urllib3",
)
top_level_help = self.run_command(
self.python, "-I", "-m", "kvcm_ops", "--help"
)
self.assertIn("KVCM script entry", top_level_help)
http_command_help = self.run_command(
self.python,
"-I",
"-m",
"kvcm_ops",
"list_instance",
"--help",
)
self.assertIn("kvcm: list_intance.", http_command_help)
if __name__ == "__main__":
unittest.main(argv=[sys.argv[0]])