Beispiel #1
0
    def test_abspath(self):
        self.assert_(macpath.abspath("xx:yy") == "xx:yy")

        # 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()
        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)
                for path in ("", "foo", "f\xf2\xf2", "/foo", "C:\\"):
                    self.assertTrue(isinstance(macpath.abspath(path), str))
                for upath in (u"", u"fuu", u"f\xf9\xf9", u"/fuu", u"U:\\"):
                    self.assertTrue(isinstance(macpath.abspath(upath), unicode))
            finally:
                os.chdir(saved_cwd)
                os.rmdir(cwd)
Beispiel #2
0
    def test_abspath(self):
        self.assert_(macpath.abspath("xx:yy") == "xx:yy")

        # 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()
        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)
                for path in ('', 'foo', 'f\xf2\xf2', '/foo', 'C:\\'):
                    self.assertTrue(isinstance(macpath.abspath(path), str))
                for upath in (u'', u'fuu', u'f\xf9\xf9', u'/fuu', u'U:\\'):
                    self.assertTrue(isinstance(macpath.abspath(upath), unicode))
            finally:
                os.chdir(saved_cwd)
                os.rmdir(cwd)
Beispiel #3
0
 def test_abspath(self):
     self.assertEqual(macpath.abspath("xx:yy"), "xx:yy")
Beispiel #4
0
 def test_abspath(self):
     self.assert_(macpath.abspath("xx:yy") == "xx:yy")