~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
            self.assertFalse(osutils.is_inside_or_parent_of_any(dirs, fn))
232
232
 
233
233
 
 
234
class TestLstat(tests.TestCaseInTempDir):
 
235
 
 
236
    def test_lstat_matches_fstat(self):
 
237
        # On Windows, lstat and fstat don't always agree, primarily in the
 
238
        # 'st_ino' and 'st_dev' fields. So we force them to be '0' in our
 
239
        # custom implementation.
 
240
        if sys.platform == 'win32':
 
241
            # We only have special lstat/fstat if we have the extension.
 
242
            # Without it, we may end up re-reading content when we don't have
 
243
            # to, but otherwise it doesn't effect correctness.
 
244
            self.requireFeature(test__walkdirs_win32.win32_readdir_feature)
 
245
        f = open('test-file.txt', 'wb')
 
246
        self.addCleanup(f.close)
 
247
        f.write('some content\n')
 
248
        f.flush()
 
249
        self.assertEqualStat(osutils.fstat(f.fileno()),
 
250
                             osutils.lstat('test-file.txt'))
 
251
 
 
252
 
234
253
class TestRmTree(tests.TestCaseInTempDir):
235
254
 
236
255
    def test_rmtree(self):
1878
1897
        os.symlink(self.target, self.link)
1879
1898
 
1880
1899
    def test_os_readlink_link_encoding(self):
1881
 
        if sys.version_info < (2, 6):
1882
 
            self.assertRaises(UnicodeEncodeError, os.readlink, self.link)
1883
 
        else:
1884
 
            self.assertEquals(self.target,  os.readlink(self.link))
 
1900
        self.assertEquals(self.target,  os.readlink(self.link))
1885
1901
 
1886
1902
    def test_os_readlink_link_decoding(self):
1887
1903
        self.assertEquals(self.target.encode(osutils._fs_enc),
2128
2144
        # revisited if we test against all implementations.
2129
2145
        self.backups.remove('file.~2~')
2130
2146
        self.assertBackupName('file.~2~', 'file')
 
2147
 
 
2148
 
 
2149
class TestFindExecutableInPath(tests.TestCase):
 
2150
 
 
2151
    def test_windows(self):
 
2152
        if sys.platform != 'win32':
 
2153
            raise tests.TestSkipped('test requires win32')
 
2154
        self.assertTrue(osutils.find_executable_on_path('explorer') is not None)
 
2155
        self.assertTrue(
 
2156
            osutils.find_executable_on_path('explorer.exe') is not None)
 
2157
        self.assertTrue(
 
2158
            osutils.find_executable_on_path('EXPLORER.EXE') is not None)
 
2159
        self.assertTrue(
 
2160
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)
 
2161
        self.assertTrue(osutils.find_executable_on_path('file.txt') is None)
 
2162
 
 
2163
    def test_other(self):
 
2164
        if sys.platform == 'win32':
 
2165
            raise tests.TestSkipped('test requires non-win32')
 
2166
        self.assertTrue(osutils.find_executable_on_path('sh') is not None)
 
2167
        self.assertTrue(
 
2168
            osutils.find_executable_on_path('THIS SHOULD NOT EXIST') is None)