~jameinel/bzr/2.5-merges-2.4

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-23 09:27:10 UTC
  • mfrom: (6015.57.6 2.4)
  • mto: This revision was merged to the branch mainline in revision 6513.
  • Revision ID: john@arbash-meinel.com-20130523092710-pw16hzoeyxwx33zv
Merge 2.4, bring up the changelogs for things that also got merged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import select
24
24
import socket
25
25
import sys
 
26
import tempfile
26
27
import time
27
28
 
28
29
from bzrlib import (
427
428
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)
428
429
 
429
430
 
 
431
class TestFdatasync(tests.TestCaseInTempDir):
 
432
 
 
433
    def do_fdatasync(self):
 
434
        f = tempfile.NamedTemporaryFile()
 
435
        osutils.fdatasync(f.fileno())
 
436
        f.close()
 
437
 
 
438
    @staticmethod
 
439
    def raise_eopnotsupp(*args, **kwargs):
 
440
        raise IOError(errno.EOPNOTSUPP, os.strerror(errno.EOPNOTSUPP))
 
441
 
 
442
    @staticmethod
 
443
    def raise_enotsup(*args, **kwargs):
 
444
        raise IOError(errno.ENOTSUP, os.strerror(errno.ENOTSUP))
 
445
 
 
446
    def test_fdatasync_handles_system_function(self):
 
447
        self.overrideAttr(os, "fdatasync")
 
448
        self.do_fdatasync()
 
449
 
 
450
    def test_fdatasync_handles_no_fdatasync_no_fsync(self):
 
451
        self.overrideAttr(os, "fdatasync")
 
452
        self.overrideAttr(os, "fsync")
 
453
        self.do_fdatasync()
 
454
 
 
455
    def test_fdatasync_handles_no_EOPNOTSUPP(self):
 
456
        self.overrideAttr(errno, "EOPNOTSUPP")
 
457
        self.do_fdatasync()
 
458
 
 
459
    def test_fdatasync_catches_ENOTSUP(self):
 
460
        enotsup = getattr(errno, "ENOTSUP", None)
 
461
        if enotsup is None:
 
462
            raise tests.TestNotApplicable("No ENOTSUP on this platform")
 
463
        self.overrideAttr(os, "fdatasync", self.raise_enotsup)
 
464
        self.do_fdatasync()
 
465
 
 
466
    def test_fdatasync_catches_EOPNOTSUPP(self):
 
467
        enotsup = getattr(errno, "EOPNOTSUPP", None)
 
468
        if enotsup is None:
 
469
            raise tests.TestNotApplicable("No EOPNOTSUPP on this platform")
 
470
        self.overrideAttr(os, "fdatasync", self.raise_eopnotsupp)
 
471
        self.do_fdatasync()
 
472
 
 
473
 
430
474
class TestLinks(tests.TestCaseInTempDir):
431
475
 
432
476
    def test_dereference_path(self):