skip tests with a non-ascii cwd when the file system encoding is ascii

This commit is contained in:
Ezio Melotti 2010-02-20 22:34:21 +00:00
parent 18d5a69669
commit 9e9af21d45
4 changed files with 33 additions and 18 deletions

View file

@ -397,6 +397,13 @@ def temp_cwd(name='tempcwd', quiet=False):
the CWD, an error is raised. If it's True, only a warning is raised
and the original CWD is used.
"""
if isinstance(name, unicode):
try:
name = name.encode(sys.getfilesystemencoding() or 'ascii')
except UnicodeEncodeError:
if not quiet:
raise unittest.SkipTest('unable to encode the cwd name with '
'the filesystem encoding.')
saved_dir = os.getcwd()
is_temporary = False
try: