~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-05 14:47:26 UTC
  • mfrom: (5752.2.11 2.4-windows-lfstat)
  • Revision ID: pqm@pqm.ubuntu.com-20110405144726-zi3lj2kwvjml4kx5
(jameinel) Add osutils.lstat/fstat so that even on Windows lstat(fname) ==
 fstat(open(fname).fileno()) (John A Meinel)

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):