~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-12-01 19:41:16 UTC
  • mfrom: (2158 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2159.
  • Revision ID: john@arbash-meinel.com-20061201194116-nvn5qhfxux5284jc
[merge] bzr.dev 2158

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
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)
199
199
 
 
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('.')
 
204
        os.mkdir('bar')
 
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'))
 
211
        
 
212
        # Does not dereference terminal symlinks
 
213
        foo_path = osutils.pathjoin(cwd, 'foo')
 
214
        self.assertEqual(foo_path, osutils.dereference_path('./foo'))
 
215
 
 
216
        # Dereferences parent symlinks
 
217
        os.mkdir('bar/baz')
 
218
        baz_path = osutils.pathjoin(bar_path, 'baz')
 
219
        self.assertEqual(baz_path, osutils.dereference_path('./foo/baz'))
 
220
 
 
221
        # Dereferences parent symlinks that are the first path element
 
222
        self.assertEqual(baz_path, osutils.dereference_path('foo/baz'))
 
223
 
 
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))
 
227
 
200
228
 
201
229
class TestSafeUnicode(TestCase):
202
230
 
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'))
509
537
 
510
538
    def test_copy_tree_target_exists(self):
511
539
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c',
512
540
                         'target/'])
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'))
516
544
 
517
545
    def test_copy_tree_symlinks(self):