141
141
self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo')
144
class TestWin32Funcs(TestCase):
145
"""Test that the _win32 versions of os utilities return appropriate paths."""
147
def test_abspath(self):
148
self.assertEqual('C:/foo', osutils._win32_abspath('C:\\foo'))
149
self.assertEqual('C:/foo', osutils._win32_abspath('C:/foo'))
151
def test_realpath(self):
152
self.assertEqual('C:/foo', osutils._win32_realpath('C:\\foo'))
153
self.assertEqual('C:/foo', osutils._win32_realpath('C:/foo'))
155
def test_pathjoin(self):
156
self.assertEqual('path/to/foo', osutils._win32_pathjoin('path', 'to', 'foo'))
157
self.assertEqual('C:/foo', osutils._win32_pathjoin('path\\to', 'C:\\foo'))
158
self.assertEqual('C:/foo', osutils._win32_pathjoin('path/to', 'C:/foo'))
159
self.assertEqual('path/to/foo', osutils._win32_pathjoin('path/to/', 'foo'))
160
self.assertEqual('/foo', osutils._win32_pathjoin('C:/path/to/', '/foo'))
161
self.assertEqual('/foo', osutils._win32_pathjoin('C:\\path\\to\\', '\\foo'))
163
def test_normpath(self):
164
self.assertEqual('path/to/foo', osutils._win32_normpath(r'path\\from\..\to\.\foo'))
165
self.assertEqual('path/to/foo', osutils._win32_normpath('path//from/../to/./foo'))
167
def test_getcwd(self):
168
self.assertEqual(os.getcwdu().replace('\\', '/'), osutils._win32_getcwd())
171
class TestWin32FuncsDirs(TestCaseInTempDir):
172
"""Test win32 functions that create files."""
174
def test_getcwd(self):
175
# Make sure getcwd can handle unicode filenames
177
os.mkdir(u'B\xe5gfors')
179
raise TestSkipped("Unable to create Unicode filename")
181
os.chdir(u'B\xe5gfors')
182
# TODO: jam 20060427 This will probably fail on Mac OSX because
183
# it will change the normalization of B\xe5gfors
184
# Consider using a different unicode character, or make
185
# osutils.getcwd() renormalize the path.
186
self.assertTrue(osutils._win32_getcwd().endswith(u'/B\xe5gfors'))
188
def test_mkdtemp(self):
189
tmpdir = osutils._win32_mkdtemp(dir='.')
190
self.assertFalse('\\' in tmpdir)
192
def test_rename(self):
200
osutils._win32_rename('b', 'a')
201
self.failUnlessExists('a')
202
self.failIfExists('b')
203
self.assertFileEqual('baz\n', 'a')
144
206
class TestSplitLines(TestCase):
146
208
def test_split_unicode(self):