/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Jelmer Vernooij
  • Date: 2009-02-25 15:36:48 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4050.
  • Revision ID: jelmer@samba.org-20090225153648-7r5mk20nr9dttqbf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 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
171
171
                         (['src'], 'src'),
172
172
                         ]:
173
173
            self.assert_(is_inside_or_parent_of_any(dirs, fn))
174
 
            
 
174
 
175
175
        for dirs, fn in [(['src'], 'srccontrol'),
176
176
                         (['srccontrol/foo.c'], 'src'),
177
177
                         (['src'], 'srccontrol/foo')]:
202
202
        if osutils.has_symlinks():
203
203
            os.symlink('symlink', 'symlink')
204
204
            self.assertEquals('symlink', osutils.file_kind('symlink'))
205
 
        
 
205
 
206
206
        # TODO: jam 20060529 Test a block device
207
207
        try:
208
208
            os.lstat('/dev/null')
310
310
        self.assertEqual(bar_path, osutils.realpath('./bar'))
311
311
        os.symlink('bar', 'foo')
312
312
        self.assertEqual(bar_path, osutils.realpath('./foo'))
313
 
        
 
313
 
314
314
        # Does not dereference terminal symlinks
315
315
        foo_path = osutils.pathjoin(cwd, 'foo')
316
316
        self.assertEqual(foo_path, osutils.dereference_path('./foo'))
692
692
 
693
693
class TestWin32FuncsDirs(TestCaseInTempDir):
694
694
    """Test win32 functions that create files."""
695
 
    
 
695
 
696
696
    def test_getcwd(self):
697
697
        if win32utils.winver == 'Windows 98':
698
698
            raise TestSkipped('Windows 98 cannot handle unicode filenames')
1330
1330
 
1331
1331
 
1332
1332
class TestCopyTree(TestCaseInTempDir):
1333
 
    
 
1333
 
1334
1334
    def test_copy_basic_tree(self):
1335
1335
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
1336
1336
        osutils.copy_tree('source', 'target')
1415
1415
 
1416
1416
    def test_unicode(self):
1417
1417
        """Environment can only contain plain strings
1418
 
        
 
1418
 
1419
1419
        So Unicode strings must be encoded.
1420
1420
        """
1421
1421
        uni_val, env_val = probe_unicode_in_user_encoding()
1471
1471
        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
1472
1472
 
1473
1473
 
1474
 
_debug_text = \
1475
 
r'''# Copyright (C) 2005, 2006 Canonical Ltd
1476
 
#
1477
 
# This program is free software; you can redistribute it and/or modify
1478
 
# it under the terms of the GNU General Public License as published by
1479
 
# the Free Software Foundation; either version 2 of the License, or
1480
 
# (at your option) any later version.
1481
 
#
1482
 
# This program is distributed in the hope that it will be useful,
1483
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1484
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1485
 
# GNU General Public License for more details.
1486
 
#
1487
 
# You should have received a copy of the GNU General Public License
1488
 
# along with this program; if not, write to the Free Software
1489
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1490
 
 
1491
 
 
1492
 
# NOTE: If update these, please also update the help for global-options in
1493
 
#       bzrlib/help_topics/__init__.py
1494
 
 
1495
 
debug_flags = set()
1496
 
"""Set of flags that enable different debug behaviour.
1497
 
 
1498
 
These are set with eg ``-Dlock`` on the bzr command line.
1499
 
 
1500
 
Options include:
1501
 
 
1502
 
 * auth - show authentication sections used
1503
 
 * error - show stack traces for all top level exceptions
1504
 
 * evil - capture call sites that do expensive or badly-scaling operations.
1505
 
 * fetch - trace history copying between repositories
1506
 
 * graph - trace graph traversal information
1507
 
 * hashcache - log every time a working file is read to determine its hash
1508
 
 * hooks - trace hook execution
1509
 
 * hpss - trace smart protocol requests and responses
1510
 
 * http - trace http connections, requests and responses
1511
 
 * index - trace major index operations
1512
 
 * knit - trace knit operations
1513
 
 * lock - trace when lockdir locks are taken or released
1514
 
 * merge - emit information for debugging merges
1515
 
 * pack - emit information about pack operations
1516
 
 
1517
 
"""
1518
 
'''
1519
 
 
1520
 
 
1521
1474
class TestResourceLoading(TestCaseInTempDir):
1522
1475
 
1523
1476
    def test_resource_string(self):
1524
1477
        # test resource in bzrlib
1525
1478
        text = osutils.resource_string('bzrlib', 'debug.py')
1526
 
        self.assertEquals(_debug_text, text)
 
1479
        self.assertContainsRe(text, "debug_flags = set()")
1527
1480
        # test resource under bzrlib
1528
1481
        text = osutils.resource_string('bzrlib.ui', 'text.py')
1529
1482
        self.assertContainsRe(text, "class TextUIFactory")