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

« back to all changes in this revision

Viewing changes to Lib/test/test_ntpath.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:
123
123
        tester("ntpath.normpath('C:////a/b')", r'C:\a\b')
124
124
        tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b')
125
125
 
 
126
        # Issue 5827: Make sure normpath preserves unicode
 
127
        for path in (u'', u'.', u'/', u'\\', u'///foo/.//bar//'):
 
128
            self.assertTrue(isinstance(ntpath.normpath(path), unicode),
 
129
                            'normpath() returned str instead of unicode')
 
130
 
126
131
    def test_expandvars(self):
127
132
        oldenv = os.environ.copy()
128
133
        try:
159
164
        # the rest of the tests for the ntpath module to be run to completion
160
165
        # on any platform, since most of the module is intended to be usable
161
166
        # from any platform.
 
167
        # XXX this needs more tests
162
168
        try:
163
169
            import nt
164
170
        except ImportError:
165
 
            pass
 
171
            # check that the function is there even if we are not on Windows
 
172
            ntpath.abspath
166
173
        else:
167
174
            tester('ntpath.abspath("C:\\")', "C:\\")
168
175
 
 
176
            # Issue 3426: check that abspath retuns unicode when the arg is
 
177
            # unicode and str when it's str, with both ASCII and non-ASCII cwds
 
178
            saved_cwd = os.getcwd()
 
179
            for cwd in (u'cwd', u'\xe7w\xf0'):
 
180
                try:
 
181
                    os.mkdir(cwd)
 
182
                    os.chdir(cwd)
 
183
                    for path in ('', 'foo', 'f\xf2\xf2', '/foo', 'C:\\'):
 
184
                        self.assertTrue(isinstance(ntpath.abspath(path), str))
 
185
                    for upath in (u'', u'fuu', u'f\xf9\xf9', u'/fuu', u'U:\\'):
 
186
                        self.assertTrue(isinstance(ntpath.abspath(upath),
 
187
                                                   unicode))
 
188
                finally:
 
189
                    os.chdir(saved_cwd)
 
190
                    os.rmdir(cwd)
 
191
 
 
192
 
169
193
    def test_relpath(self):
170
194
        currentdir = os.path.split(os.getcwd())[-1]
171
195
        tester('ntpath.relpath("a")', 'a')