File tree 5 files changed +11
-29
lines changed
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 2
2
3
3
4
4
os_helper = try_import ('os_helper' ) or from_test_support (
5
- 'FS_NONASCII' , 'skip_unless_symlink'
5
+ 'FS_NONASCII' , 'skip_unless_symlink' , 'temp_dir'
6
6
)
7
7
import_helper = try_import ('import_helper' ) or from_test_support (
8
8
'modules_setup' , 'modules_cleanup'
Original file line number Diff line number Diff line change 1
- import os
2
1
import sys
3
2
import copy
4
3
import json
5
4
import shutil
6
5
import pathlib
7
- import tempfile
8
6
import textwrap
9
7
import functools
10
8
import contextlib
26
24
27
25
28
26
@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 )
52
33
53
34
54
35
@contextlib .contextmanager
@@ -69,7 +50,7 @@ def setUp(self):
69
50
class SiteDir (Fixtures ):
70
51
def setUp (self ):
71
52
super ().setUp ()
72
- self .site_dir = self .fixtures .enter_context (tempdir ())
53
+ self .site_dir = self .fixtures .enter_context (tmp_path ())
73
54
74
55
75
56
class OnSysPath (Fixtures ):
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ def test_entry_points_unique_packages_normalized(self):
109
109
Entry points should only be exposed for the first package
110
110
on sys.path with a given name (even when normalized).
111
111
"""
112
- alt_site_dir = self .fixtures .enter_context (fixtures .tempdir ())
112
+ alt_site_dir = self .fixtures .enter_context (fixtures .tmp_path ())
113
113
self .fixtures .enter_context (self .add_sys_path (alt_site_dir ))
114
114
alt_pkg = {
115
115
"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):
135
135
fixtures .build_files (self .make_pkg ('abc' ), self .site_dir )
136
136
before = list (_unique (distributions ()))
137
137
138
- alt_site_dir = self .fixtures .enter_context (fixtures .tempdir ())
138
+ alt_site_dir = self .fixtures .enter_context (fixtures .tmp_path ())
139
139
self .fixtures .enter_context (self .add_sys_path (alt_site_dir ))
140
140
fixtures .build_files (self .make_pkg ('ABC' ), alt_site_dir )
141
141
after = list (_unique (distributions ()))
You can’t perform that action at this time.
0 commit comments