~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
 
94
94
    # TODO: test fancy_rename using a MemoryTransport
95
95
 
 
96
    def test_rename_change_case(self):
 
97
        # on Windows we should be able to change filename case by rename
 
98
        self.build_tree(['a', 'b/'])
 
99
        osutils.rename('a', 'A')
 
100
        osutils.rename('b', 'B')
 
101
        # we can't use failUnlessExists on case-insensitive filesystem
 
102
        # so try to check shape of the tree
 
103
        shape = sorted(os.listdir('.'))
 
104
        self.assertEquals(['A', 'B'], shape)
 
105
 
96
106
    def test_01_rand_chars_empty(self):
97
107
        result = osutils.rand_chars(0)
98
108
        self.assertEqual(result, '')
250
260
        self.assertFormatedDelta('1 second in the future', -1)
251
261
        self.assertFormatedDelta('2 seconds in the future', -2)
252
262
 
 
263
    def test_format_date(self):
 
264
        self.assertRaises(errors.UnsupportedTimezoneFormat,
 
265
            osutils.format_date, 0, timezone='foo')
 
266
 
253
267
    def test_dereference_path(self):
254
268
        self.requireFeature(SymlinkFeature)
255
269
        cwd = osutils.realpath('.')
1061
1075
        self.build_tree_contents([('foo', text)])
1062
1076
        expected_sha = osutils.sha_string(text)
1063
1077
        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
 
1078
 
 
1079
 
 
1080
_debug_text = \
 
1081
r'''# Copyright (C) 2005, 2006 Canonical Ltd
 
1082
#
 
1083
# This program is free software; you can redistribute it and/or modify
 
1084
# it under the terms of the GNU General Public License as published by
 
1085
# the Free Software Foundation; either version 2 of the License, or
 
1086
# (at your option) any later version.
 
1087
#
 
1088
# This program is distributed in the hope that it will be useful,
 
1089
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
1090
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
1091
# GNU General Public License for more details.
 
1092
#
 
1093
# You should have received a copy of the GNU General Public License
 
1094
# along with this program; if not, write to the Free Software
 
1095
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
1096
 
 
1097
 
 
1098
# NOTE: If update these, please also update the help for global-options in
 
1099
#       bzrlib/help_topics/__init__.py
 
1100
 
 
1101
debug_flags = set()
 
1102
"""Set of flags that enable different debug behaviour.
 
1103
 
 
1104
These are set with eg ``-Dlock`` on the bzr command line.
 
1105
 
 
1106
Options include:
 
1107
 
 
1108
 * auth - show authentication sections used
 
1109
 * error - show stack traces for all top level exceptions
 
1110
 * evil - capture call sites that do expensive or badly-scaling operations.
 
1111
 * fetch - trace history copying between repositories
 
1112
 * hashcache - log every time a working file is read to determine its hash
 
1113
 * hooks - trace hook execution
 
1114
 * hpss - trace smart protocol requests and responses
 
1115
 * http - trace http connections, requests and responses
 
1116
 * index - trace major index operations
 
1117
 * knit - trace knit operations
 
1118
 * lock - trace when lockdir locks are taken or released
 
1119
 * merge - emit information for debugging merges
 
1120
 
 
1121
"""
 
1122
'''
 
1123
 
 
1124
 
 
1125
class TestResourceLoading(TestCaseInTempDir):
 
1126
 
 
1127
    def test_resource_string(self):
 
1128
        # test resource in bzrlib
 
1129
        text = osutils.resource_string('bzrlib', 'debug.py')
 
1130
        self.assertEquals(_debug_text, text)
 
1131
        # test resource under bzrlib
 
1132
        text = osutils.resource_string('bzrlib.ui', 'text.py')
 
1133
        self.assertContainsRe(text, "class TextUIFactory")
 
1134
        # test unsupported package
 
1135
        self.assertRaises(errors.BzrError, osutils.resource_string, 'zzzz',
 
1136
            'yyy.xx')
 
1137
        # test unknown resource
 
1138
        self.assertRaises(IOError, osutils.resource_string, 'bzrlib', 'yyy.xx')