~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-15 09:21:49 UTC
  • mfrom: (6606.2.1 autodoc-unicode)
  • Revision ID: pqm@pqm.ubuntu.com-20160115092149-z5f4sfq3jvaz0enb
(vila) Fix autodoc runner when LANG=C. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2016 Canonical Ltd
 
1
# Copyright (C) 2005-2015 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
180
180
        # we can't use failUnlessExists on case-insensitive filesystem
181
181
        # so try to check shape of the tree
182
182
        shape = sorted(os.listdir('.'))
183
 
        self.assertEqual(['A', 'B'], shape)
 
183
        self.assertEquals(['A', 'B'], shape)
184
184
 
185
185
    def test_rename_exception(self):
186
186
        try:
222
222
                         (['src'], SRC_FOO_C),
223
223
                         (['src'], 'src'),
224
224
                         ]:
225
 
            self.assertTrue(osutils.is_inside_any(dirs, fn))
 
225
            self.assert_(osutils.is_inside_any(dirs, fn))
226
226
        for dirs, fn in [(['src'], 'srccontrol'),
227
227
                         (['src'], 'srccontrol/foo')]:
228
228
            self.assertFalse(osutils.is_inside_any(dirs, fn))
234
234
                         (['src/bar.c', 'bla/foo.c'], 'src'),
235
235
                         (['src'], 'src'),
236
236
                         ]:
237
 
            self.assertTrue(osutils.is_inside_or_parent_of_any(dirs, fn))
 
237
            self.assert_(osutils.is_inside_or_parent_of_any(dirs, fn))
238
238
 
239
239
        for dirs, fn in [(['src'], 'srccontrol'),
240
240
                         (['srccontrol/foo.c'], 'src'),
298
298
 
299
299
    def test_file_kind(self):
300
300
        self.build_tree(['file', 'dir/'])
301
 
        self.assertEqual('file', osutils.file_kind('file'))
302
 
        self.assertEqual('directory', osutils.file_kind('dir/'))
 
301
        self.assertEquals('file', osutils.file_kind('file'))
 
302
        self.assertEquals('directory', osutils.file_kind('dir/'))
303
303
        if osutils.has_symlinks():
304
304
            os.symlink('symlink', 'symlink')
305
 
            self.assertEqual('symlink', osutils.file_kind('symlink'))
 
305
            self.assertEquals('symlink', osutils.file_kind('symlink'))
306
306
 
307
307
        # TODO: jam 20060529 Test a block device
308
308
        try:
311
311
            if e.errno not in (errno.ENOENT,):
312
312
                raise
313
313
        else:
314
 
            self.assertEqual('chardev', osutils.file_kind('/dev/null'))
 
314
            self.assertEquals('chardev', osutils.file_kind('/dev/null'))
315
315
 
316
316
        mkfifo = getattr(os, 'mkfifo', None)
317
317
        if mkfifo:
318
318
            mkfifo('fifo')
319
319
            try:
320
 
                self.assertEqual('fifo', osutils.file_kind('fifo'))
 
320
                self.assertEquals('fifo', osutils.file_kind('fifo'))
321
321
            finally:
322
322
                os.remove('fifo')
323
323
 
326
326
            s = socket.socket(AF_UNIX)
327
327
            s.bind('socket')
328
328
            try:
329
 
                self.assertEqual('socket', osutils.file_kind('socket'))
 
329
                self.assertEquals('socket', osutils.file_kind('socket'))
330
330
            finally:
331
331
                os.remove('socket')
332
332
 
1205
1205
        # (It would be ok if it happened earlier but at the moment it
1206
1206
        # doesn't.)
1207
1207
        e = self.assertRaises(OSError, list, osutils._walkdirs_utf8("."))
1208
 
        self.assertEqual('./test-unreadable', e.filename)
1209
 
        self.assertEqual(errno.EACCES, e.errno)
 
1208
        self.assertEquals('./test-unreadable', e.filename)
 
1209
        self.assertEquals(errno.EACCES, e.errno)
1210
1210
        # Ensure the message contains the file name
1211
1211
        self.assertContainsRe(str(e), "\./test-unreadable")
1212
1212
 
2003
2003
        os.symlink(self.target, self.link)
2004
2004
 
2005
2005
    def test_os_readlink_link_encoding(self):
2006
 
        self.assertEqual(self.target,  os.readlink(self.link))
 
2006
        self.assertEquals(self.target,  os.readlink(self.link))
2007
2007
 
2008
2008
    def test_os_readlink_link_decoding(self):
2009
 
        self.assertEqual(self.target.encode(osutils._fs_enc),
 
2009
        self.assertEquals(self.target.encode(osutils._fs_enc),
2010
2010
                          os.readlink(self.link.encode(osutils._fs_enc)))
2011
2011
 
2012
2012
 
2032
2032
        self.overrideEnv('BZR_CONCURRENCY', '1')
2033
2033
        self.run_bzr('rocks --concurrency 42')
2034
2034
        # Command line overrides environment variable
2035
 
        self.assertEqual('42', os.environ['BZR_CONCURRENCY'])
2036
 
        self.assertEqual(42, osutils.local_concurrency(use_cache=False))
 
2035
        self.assertEquals('42', os.environ['BZR_CONCURRENCY'])
 
2036
        self.assertEquals(42, osutils.local_concurrency(use_cache=False))
2037
2037
 
2038
2038
 
2039
2039
class TestFailedToLoadExtension(tests.TestCase):
2052
2052
    def test_failure_to_load(self):
2053
2053
        self._try_loading()
2054
2054
        self.assertLength(1, osutils._extension_load_failures)
2055
 
        self.assertEqual(osutils._extension_load_failures[0],
 
2055
        self.assertEquals(osutils._extension_load_failures[0],
2056
2056
            "No module named _fictional_extension_py")
2057
2057
 
2058
2058
    def test_report_extension_load_failures_no_warning(self):
2179
2179
        osutils.copy_ownership_from_path('test_file', ownsrc)
2180
2180
 
2181
2181
        s = os.stat(ownsrc)
2182
 
        self.assertEqual(self.path, 'test_file')
2183
 
        self.assertEqual(self.uid, s.st_uid)
2184
 
        self.assertEqual(self.gid, s.st_gid)
 
2182
        self.assertEquals(self.path, 'test_file')
 
2183
        self.assertEquals(self.uid, s.st_uid)
 
2184
        self.assertEquals(self.gid, s.st_gid)
2185
2185
 
2186
2186
    def test_copy_ownership_nonesrc(self):
2187
2187
        """copy_ownership_from_path test with src=None."""
2190
2190
        osutils.copy_ownership_from_path('test_file')
2191
2191
 
2192
2192
        s = os.stat('..')
2193
 
        self.assertEqual(self.path, 'test_file')
2194
 
        self.assertEqual(self.uid, s.st_uid)
2195
 
        self.assertEqual(self.gid, s.st_gid)
 
2193
        self.assertEquals(self.path, 'test_file')
 
2194
        self.assertEquals(self.uid, s.st_uid)
 
2195
        self.assertEquals(self.gid, s.st_gid)
2196
2196
 
2197
2197
 
2198
2198
class TestPathFromEnviron(tests.TestCase):