summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTzu-ping Chung <uranusjr@gmail.com>2022-06-07 17:52:38 +0800
committerTzu-ping Chung <uranusjr@gmail.com>2022-06-08 19:58:46 +0800
commit42359a9605d56a37ac9a1ca76ea08a3b01d48468 (patch)
treecca953006162a2e2940e4a260a84583b1b8ebb10 /tools
parente58a8a591b72f5f022ddd84c0c03e4bfe90d9040 (diff)
downloadpip-42359a9605d56a37ac9a1ca76ea08a3b01d48468.tar.gz
Migrate tests to use pathlib.Path
The pip-specific Path implementation has been removed, and all its usages replaced by pathlib.Path. The tmpdir and tmpdir_factory fixtures are also removed, and all usages are replaced by tmp_path and tmp_path_factory, which use pathlib.Path. The pip() function now also accepts pathlib.Path so we don't need to put str() everywhere. Path arguments are coerced with os.fspath() into str.
Diffstat (limited to 'tools')
-rw-r--r--tools/protected_pip.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/protected_pip.py b/tools/protected_pip.py
index 671518029..48230719e 100644
--- a/tools/protected_pip.py
+++ b/tools/protected_pip.py
@@ -1,15 +1,16 @@
import os
+import pathlib
import shutil
import subprocess
import sys
from glob import glob
-from typing import List
+from typing import Iterable, Union
VIRTUAL_ENV = os.environ["VIRTUAL_ENV"]
TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, "pip")
-def pip(args: List[str]) -> None:
+def pip(args: Iterable[Union[str, pathlib.Path]]) -> None:
# First things first, get a recent (stable) version of pip.
if not os.path.exists(TOX_PIP_DIR):
subprocess.check_call(
@@ -30,7 +31,7 @@ def pip(args: List[str]) -> None:
pypath = pypath_env.split(os.pathsep) if pypath_env is not None else []
pypath.insert(0, TOX_PIP_DIR)
os.environ["PYTHONPATH"] = os.pathsep.join(pypath)
- subprocess.check_call([sys.executable, "-m", "pip"] + args)
+ subprocess.check_call([sys.executable, "-m", "pip", *(os.fspath(a) for a in args)])
if __name__ == "__main__":