~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/test/test_macpath.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
1
3
import macpath
2
4
from test import test_support
3
5
import unittest
8
10
    def test_abspath(self):
9
11
        self.assert_(macpath.abspath("xx:yy") == "xx:yy")
10
12
 
 
13
        # Issue 3426: check that abspath retuns unicode when the arg is unicode
 
14
        # and str when it's str, with both ASCII and non-ASCII cwds
 
15
        saved_cwd = os.getcwd()
 
16
        cwds = ['cwd']
 
17
        try:
 
18
            cwds.append(u'\xe7w\xf0'.encode(sys.getfilesystemencoding()
 
19
                                            or 'ascii'))
 
20
        except UnicodeEncodeError:
 
21
            pass # the cwd can't be encoded -- test with ascii cwd only
 
22
        for cwd in cwds:
 
23
            try:
 
24
                os.mkdir(cwd)
 
25
                os.chdir(cwd)
 
26
                for path in ('', 'foo', 'f\xf2\xf2', '/foo', 'C:\\'):
 
27
                    self.assertTrue(isinstance(macpath.abspath(path), str))
 
28
                for upath in (u'', u'fuu', u'f\xf9\xf9', u'/fuu', u'U:\\'):
 
29
                    self.assertTrue(isinstance(macpath.abspath(upath), unicode))
 
30
            finally:
 
31
                os.chdir(saved_cwd)
 
32
                os.rmdir(cwd)
 
33
 
 
34
 
11
35
    def test_isabs(self):
12
36
        isabs = macpath.isabs
13
37
        self.assert_(isabs("xx:yy"))