~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-15 18:09:55 UTC
  • mfrom: (5159.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100415180955-v9jh960r07pva92c
(vila) Merge 2.1 into bzr.dev including fixes for #262450, #373898,
        #498409

Show diffs side-by-side

added added

removed removed

Lines of Context:
4435
4435
            return result
4436
4436
except ImportError:
4437
4437
    pass
 
4438
 
 
4439
class _PosixPermissionsFeature(Feature):
 
4440
 
 
4441
    def _probe(self):
 
4442
        def has_perms():
 
4443
            # create temporary file and check if specified perms are maintained.
 
4444
            import tempfile
 
4445
 
 
4446
            write_perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
 
4447
            f = tempfile.mkstemp(prefix='bzr_perms_chk_')
 
4448
            fd, name = f
 
4449
            os.close(fd)
 
4450
            os.chmod(name, write_perms)
 
4451
 
 
4452
            read_perms = os.stat(name).st_mode & 0777
 
4453
            os.unlink(name)
 
4454
            return (write_perms == read_perms)
 
4455
 
 
4456
        return (os.name == 'posix') and has_perms()
 
4457
 
 
4458
    def feature_name(self):
 
4459
        return 'POSIX permissions support'
 
4460
 
 
4461
posix_permissions_feature = _PosixPermissionsFeature()