1
# Copyright (C) 2005 Canonical Ltd
1
# Copyright (C) 2005, 2006 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):
504
532
def test_copy_basic_tree(self):
505
533
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
506
534
osutils.copy_tree('source', 'target')
507
self.assertEqual(['a', 'b'], os.listdir('target'))
535
self.assertEqual(['a', 'b'], sorted(os.listdir('target')))
508
536
self.assertEqual(['c'], os.listdir('target/b'))
510
538
def test_copy_tree_target_exists(self):
511
539
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c',
513
541
osutils.copy_tree('source', 'target')
514
self.assertEqual(['a', 'b'], os.listdir('target'))
542
self.assertEqual(['a', 'b'], sorted(os.listdir('target')))
515
543
self.assertEqual(['c'], os.listdir('target/b'))
517
545
def test_copy_tree_symlinks(self):