import os
+import sys
import macpath
from test import test_support
import unittest
# Issue 3426: check that abspath retuns unicode when the arg is unicode
# and str when it's str, with both ASCII and non-ASCII cwds
saved_cwd = os.getcwd()
- for cwd in (u'cwd', u'\xe7w\xf0'):
+ cwds = ['cwd']
+ try:
+ cwds.append(u'\xe7w\xf0'.encode(sys.getfilesystemencoding()
+ or 'ascii'))
+ except UnicodeEncodeError:
+ pass # the cwd can't be encoded -- test with ascii cwd only
+ for cwd in cwds:
try:
os.mkdir(cwd)
os.chdir(cwd)
import unittest
from test import test_support
-import posixpath, os
+import posixpath, os, sys
from posixpath import realpath, abspath, dirname, basename
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# Issue 3426: check that abspath retuns unicode when the arg is unicode
# and str when it's str, with both ASCII and non-ASCII cwds
saved_cwd = os.getcwd()
- for cwd in (u'cwd', u'\xe7w\xf0'):
+ cwds = ['cwd']
+ try:
+ cwds.append(u'\xe7w\xf0'.encode(sys.getfilesystemencoding()
+ or 'ascii'))
+ except UnicodeEncodeError:
+ pass # the cwd can't be encoded -- test with ascii cwd only
+ for cwd in cwds:
try:
os.mkdir(cwd)
os.chdir(cwd)