From d46f7d209b0d6db48f63c8317df9bfefbed73ae7 Mon Sep 17 00:00:00 2001 From: Jesus Cea Date: Sat, 7 Jul 2012 14:56:04 +0200 Subject: [PATCH] Cope with OSs lying - #10142: Support for SEEK_HOLE/SEEK_DATA --- Lib/test/test_posix.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 9bedc7d2377..f0ad92f8ea7 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1017,9 +1017,6 @@ class PosixTester(unittest.TestCase): @unittest.skipUnless(hasattr(os, 'SEEK_HOLE'), "test needs an OS that reports file holes") - @unittest.skipIf(sys.platform in ('freebsd7', 'freebsd8', 'freebsd9'), - "Skip test because known kernel bug - " \ - "http://lists.freebsd.org/pipermail/freebsd-amd64/2012-January/014332.html") def test_fs_holes(self): # Even if the filesystem doesn't report holes, # if the OS supports it the SEEK_* constants @@ -1032,11 +1029,18 @@ class PosixTester(unittest.TestCase): fp.flush() size = fp.tell() fno = fp.fileno() - for i in range(size): - self.assertEqual(i, os.lseek(fno, i, os.SEEK_DATA)) - self.assertLessEqual(size, os.lseek(fno, i, os.SEEK_HOLE)) - self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_DATA) - self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_HOLE) + try : + for i in range(size): + self.assertEqual(i, os.lseek(fno, i, os.SEEK_DATA)) + self.assertLessEqual(size, os.lseek(fno, i, os.SEEK_HOLE)) + self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_DATA) + self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_HOLE) + except OSError : + # Some OSs claim to support SEEK_HOLE/SEEK_DATA + # but it is not true. + # For instance: + # http://lists.freebsd.org/pipermail/freebsd-amd64/2012-January/014332.html + raise unittest.SkipTest("OSError raised!") class PosixGroupsTester(unittest.TestCase):