Assert that the permission bits of a file are as expected. Args: path: File to stat. expected: `int`; a subset of 0o777. Raises: AssertionError: If the permissions bits of `path` do not match `expected`.
(self, path, expected)
| 272 | return os.listdir(self.info_dir) |
| 273 | |
| 274 | def assertMode(self, path, expected): |
| 275 | """Assert that the permission bits of a file are as expected. |
| 276 | |
| 277 | Args: |
| 278 | path: File to stat. |
| 279 | expected: `int`; a subset of 0o777. |
| 280 | |
| 281 | Raises: |
| 282 | AssertionError: If the permissions bits of `path` do not match |
| 283 | `expected`. |
| 284 | """ |
| 285 | stat_result = os.stat(path) |
| 286 | format_mode = lambda m: "0o%03o" % m |
| 287 | self.assertEqual( |
| 288 | format_mode(stat_result.st_mode & 0o777), |
| 289 | format_mode(expected), |
| 290 | ) |
| 291 | |
| 292 | def test_fails_if_info_dir_name_is_taken_by_a_regular_file(self): |
| 293 | os.rmdir(self.info_dir) |
no test coverage detected