427
428
self.assertTrue(-eighteen_hours < offset < eighteen_hours)
431
class TestFdatasync(tests.TestCaseInTempDir):
433
def do_fdatasync(self):
434
f = tempfile.NamedTemporaryFile()
435
osutils.fdatasync(f.fileno())
439
def raise_eopnotsupp(*args, **kwargs):
440
raise IOError(errno.EOPNOTSUPP, os.strerror(errno.EOPNOTSUPP))
443
def raise_enotsup(*args, **kwargs):
444
raise IOError(errno.ENOTSUP, os.strerror(errno.ENOTSUP))
446
def test_fdatasync_handles_system_function(self):
447
self.overrideAttr(os, "fdatasync")
450
def test_fdatasync_handles_no_fdatasync_no_fsync(self):
451
self.overrideAttr(os, "fdatasync")
452
self.overrideAttr(os, "fsync")
455
def test_fdatasync_handles_no_EOPNOTSUPP(self):
456
self.overrideAttr(errno, "EOPNOTSUPP")
459
def test_fdatasync_catches_ENOTSUP(self):
460
enotsup = getattr(errno, "ENOTSUP", None)
462
raise tests.TestNotApplicable("No ENOTSUP on this platform")
463
self.overrideAttr(os, "fdatasync", self.raise_enotsup)
466
def test_fdatasync_catches_EOPNOTSUPP(self):
467
enotsup = getattr(errno, "EOPNOTSUPP", None)
469
raise tests.TestNotApplicable("No EOPNOTSUPP on this platform")
470
self.overrideAttr(os, "fdatasync", self.raise_eopnotsupp)
430
474
class TestLinks(tests.TestCaseInTempDir):
432
476
def test_dereference_path(self):