def test_permissionsFromStat(self):
        """
        L{Permissions}'s constructor takes a valid permissions bitmask and
        parsaes it to produce the correct set of boolean permissions.
        """
        def _rwxFromStat(statModeInt, who):
            def getPermissionBit(what, who):
                return (statModeInt &
                        getattr(stat, "S_I%s%s" % (what, who))) > 0
            return filepath.RWX(*[getPermissionBit(what, who) for what in
                         ('R', 'W', 'X')])

        for u in range(0, 8):
            for g in range(0, 8):
                for o in range(0, 8):
                    chmodString = "%d%d%d" % (u, g, o)
                    chmodVal = int(chmodString, 8)
                    perm = filepath.Permissions(chmodVal)
                    self.assertEqual(perm.user,
                                      _rwxFromStat(chmodVal, "USR"),
                                      "%s: got user: %s" %
                                      (chmodString, perm.user))
                    self.assertEqual(perm.group,
                                      _rwxFromStat(chmodVal, "GRP"),
                                      "%s: got group: %s" %
                                      (chmodString, perm.group))
                    self.assertEqual(perm.other,
                                      _rwxFromStat(chmodVal, "OTH"),
                                      "%s: got other: %s" %
                                      (chmodString, perm.other))
        perm = filepath.Permissions(0o777)
        for who in ("user", "group", "other"):
            for what in ("read", "write", "execute"):
                self.assertTrue(getattr(getattr(perm, who), what))

        L{Permissions}'s constructor takes a valid permissions bitmask and
        parsaes it to produce the correct set of boolean permissions.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_paths.py