1
# Copyright (C) 2005 by Canonical Ltd
1
# Copyright (C) 2005 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
197
197
self.assertFormatedDelta('1 second in the future', -1)
198
198
self.assertFormatedDelta('2 seconds in the future', -2)
200
def test_dereference_path(self):
201
if not osutils.has_symlinks():
202
raise TestSkipped('Symlinks are not supported on this platform')
203
cwd = osutils.realpath('.')
205
bar_path = osutils.pathjoin(cwd, 'bar')
206
# Using './' to avoid bug #1213894 (first path component not
207
# dereferenced) in Python 2.4.1 and earlier
208
self.assertEqual(bar_path, osutils.realpath('./bar'))
209
os.symlink('bar', 'foo')
210
self.assertEqual(bar_path, osutils.realpath('./foo'))
212
# Does not dereference terminal symlinks
213
foo_path = osutils.pathjoin(cwd, 'foo')
214
self.assertEqual(foo_path, osutils.dereference_path('./foo'))
216
# Dereferences parent symlinks
218
baz_path = osutils.pathjoin(bar_path, 'baz')
219
self.assertEqual(baz_path, osutils.dereference_path('./foo/baz'))
221
# Dereferences parent symlinks that are the first path element
222
self.assertEqual(baz_path, osutils.dereference_path('foo/baz'))
224
# Dereferences parent symlinks in absolute paths
225
foo_baz_path = osutils.pathjoin(foo_path, 'baz')
226
self.assertEqual(baz_path, osutils.dereference_path(foo_baz_path))
201
229
class TestSafeUnicode(TestCase):