File tree Expand file tree Collapse file tree 5 files changed +11
-29
lines changed
Expand file tree Collapse file tree 5 files changed +11
-29
lines changed Original file line number Diff line number Diff line change 1+ Updated fixtures for python/cpython#120801.
Original file line number Diff line number Diff line change 22
33
44os_helper = try_import ('os_helper' ) or from_test_support (
5- 'FS_NONASCII' , 'skip_unless_symlink'
5+ 'FS_NONASCII' , 'skip_unless_symlink' , 'temp_dir'
66)
77import_helper = try_import ('import_helper' ) or from_test_support (
88 'modules_setup' , 'modules_cleanup'
Original file line number Diff line number Diff line change 1- import os
21import sys
32import copy
43import json
54import shutil
65import pathlib
7- import tempfile
86import textwrap
97import functools
108import contextlib
2624
2725
2826@contextlib .contextmanager
29- def tempdir ():
30- tmpdir = tempfile .mkdtemp ()
31- try :
32- yield pathlib .Path (tmpdir )
33- finally :
34- shutil .rmtree (tmpdir )
35-
36-
37- @contextlib .contextmanager
38- def save_cwd ():
39- orig = os .getcwd ()
40- try :
41- yield
42- finally :
43- os .chdir (orig )
44-
45-
46- @contextlib .contextmanager
47- def tempdir_as_cwd ():
48- with tempdir () as tmp :
49- with save_cwd ():
50- os .chdir (str (tmp ))
51- yield tmp
27+ def tmp_path ():
28+ """
29+ Like os_helper.temp_dir, but yields a pathlib.Path.
30+ """
31+ with os_helper .temp_dir () as path :
32+ yield pathlib .Path (path )
5233
5334
5435@contextlib .contextmanager
@@ -69,7 +50,7 @@ def setUp(self):
6950class SiteDir (Fixtures ):
7051 def setUp (self ):
7152 super ().setUp ()
72- self .site_dir = self .fixtures .enter_context (tempdir ())
53+ self .site_dir = self .fixtures .enter_context (tmp_path ())
7354
7455
7556class OnSysPath (Fixtures ):
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def test_entry_points_unique_packages_normalized(self):
109109 Entry points should only be exposed for the first package
110110 on sys.path with a given name (even when normalized).
111111 """
112- alt_site_dir = self .fixtures .enter_context (fixtures .tempdir ())
112+ alt_site_dir = self .fixtures .enter_context (fixtures .tmp_path ())
113113 self .fixtures .enter_context (self .add_sys_path (alt_site_dir ))
114114 alt_pkg = {
115115 "DistInfo_pkg-1.1.0.dist-info" : {
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ def test_unique_distributions(self):
135135 fixtures .build_files (self .make_pkg ('abc' ), self .site_dir )
136136 before = list (_unique (distributions ()))
137137
138- alt_site_dir = self .fixtures .enter_context (fixtures .tempdir ())
138+ alt_site_dir = self .fixtures .enter_context (fixtures .tmp_path ())
139139 self .fixtures .enter_context (self .add_sys_path (alt_site_dir ))
140140 fixtures .build_files (self .make_pkg ('ABC' ), alt_site_dir )
141141 after = list (_unique (distributions ()))
You can’t perform that action at this time.
0 commit comments