~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-15 15:03:15 UTC
  • mfrom: (4797.42.3 2.1-integration)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: v.ladeuil+lp@free.fr-20100415150315-y2bbh2tzvshyzet0
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()