(self, chmod_func, target, **kwargs)
| 1054 | posix.utime(os_helper.TESTFN, (now, now)) |
| 1055 | |
| 1056 | def check_chmod(self, chmod_func, target, **kwargs): |
| 1057 | closefd = not isinstance(target, int) |
| 1058 | mode = os.stat(target).st_mode |
| 1059 | try: |
| 1060 | new_mode = mode & ~(stat.S_IWOTH | stat.S_IWGRP | stat.S_IWUSR) |
| 1061 | chmod_func(target, new_mode, **kwargs) |
| 1062 | self.assertEqual(os.stat(target).st_mode, new_mode) |
| 1063 | if stat.S_ISREG(mode): |
| 1064 | try: |
| 1065 | with open(target, 'wb+', closefd=closefd): |
| 1066 | pass |
| 1067 | except PermissionError: |
| 1068 | pass |
| 1069 | new_mode = mode | (stat.S_IWOTH | stat.S_IWGRP | stat.S_IWUSR) |
| 1070 | chmod_func(target, new_mode, **kwargs) |
| 1071 | self.assertEqual(os.stat(target).st_mode, new_mode) |
| 1072 | if stat.S_ISREG(mode): |
| 1073 | with open(target, 'wb+', closefd=closefd): |
| 1074 | pass |
| 1075 | finally: |
| 1076 | chmod_func(target, mode) |
| 1077 | |
| 1078 | @os_helper.skip_unless_working_chmod |
| 1079 | def test_chmod_file(self): |
no test coverage detected