Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4462)

Side by Side Diff: Lib/packaging/tests/support.py

Issue 12112: The new packaging module should not use the locale encoding
Patch Set: Created 2 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/packaging/metadata.py ('k') | Lib/packaging/tests/test_create.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Support code for packaging test cases. 1 """Support code for packaging test cases.
2 2
3 A few helper classes are provided: LoggingCatcher, TempdirManager and 3 A few helper classes are provided: LoggingCatcher, TempdirManager and
4 EnvironRestorer. They are written to be used as mixins:: 4 EnvironRestorer. They are written to be used as mixins::
5 5
6 from packaging.tests import unittest 6 from packaging.tests import unittest
7 from packaging.tests.support import LoggingCatcher 7 from packaging.tests.support import LoggingCatcher
8 8
9 class SomeTestCase(LoggingCatcher, unittest.TestCase): 9 class SomeTestCase(LoggingCatcher, unittest.TestCase):
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return d 139 return d
140 140
141 def write_file(self, path, content='xxx'): 141 def write_file(self, path, content='xxx'):
142 """Write a file at the given path. 142 """Write a file at the given path.
143 143
144 path can be a string, a tuple or a list; if it's a tuple or list, 144 path can be a string, a tuple or a list; if it's a tuple or list,
145 os.path.join will be used to produce a path. 145 os.path.join will be used to produce a path.
146 """ 146 """
147 if isinstance(path, (list, tuple)): 147 if isinstance(path, (list, tuple)):
148 path = os.path.join(*path) 148 path = os.path.join(*path)
149 f = open(path, 'w') 149 f = open(path, 'w', encoding='utf8')
150 try: 150 try:
151 f.write(content) 151 f.write(content)
152 finally: 152 finally:
153 f.close() 153 f.close()
154 154
155 def create_dist(self, **kw): 155 def create_dist(self, **kw):
156 """Create a stub distribution object and files. 156 """Create a stub distribution object and files.
157 157
158 This function creates a Distribution instance (use keyword arguments 158 This function creates a Distribution instance (use keyword arguments
159 to customize it) and a temporary directory with a project structure 159 to customize it) and a temporary directory with a project structure
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 d.parse_config_files() 250 d.parse_config_files()
251 d.parse_command_line() 251 d.parse_command_line()
252 return d 252 return d
253 253
254 254
255 try: 255 try:
256 from test.support import skip_unless_symlink 256 from test.support import skip_unless_symlink
257 except ImportError: 257 except ImportError:
258 skip_unless_symlink = unittest.skip( 258 skip_unless_symlink = unittest.skip(
259 'requires test.support.skip_unless_symlink') 259 'requires test.support.skip_unless_symlink')
OLDNEW
« no previous file with comments | « Lib/packaging/metadata.py ('k') | Lib/packaging/tests/test_create.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7