diff options
| author | Claude Paroz <claude@2xlibre.net> | 2024-12-20 23:26:22 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-23 11:36:43 +0100 |
| commit | 2c47207b3c8412d16e61e388f176b47b41b40794 (patch) | |
| tree | 778e715d81881f70feb53c49b3766d298ec050ac /tests | |
| parent | 29ba75e6e57414f0e6f9528d08a520b8b931fb28 (diff) | |
Fixed #36010 -- Avoided touching mo files while checking writability.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/test_compilation.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/i18n/test_compilation.py b/tests/i18n/test_compilation.py index 7b02776dbe..4b0bb9f6bb 100644 --- a/tests/i18n/test_compilation.py +++ b/tests/i18n/test_compilation.py @@ -43,9 +43,9 @@ class PoFileTests(MessageCompilationTests): def test_no_write_access(self): mo_file_en = Path(self.MO_FILE_EN) err_buffer = StringIO() - # Put file in read-only mode. - old_mode = mo_file_en.stat().st_mode - mo_file_en.chmod(stat.S_IREAD) + # Put parent directory in read-only mode. + old_mode = mo_file_en.parent.stat().st_mode + mo_file_en.parent.chmod(stat.S_IRUSR | stat.S_IXUSR) # Ensure .po file is more recent than .mo file. mo_file_en.with_suffix(".po").touch() try: @@ -57,7 +57,7 @@ class PoFileTests(MessageCompilationTests): ) self.assertIn("not writable location", err_buffer.getvalue()) finally: - mo_file_en.chmod(old_mode) + mo_file_en.parent.chmod(old_mode) def test_no_compile_when_unneeded(self): mo_file_en = Path(self.MO_FILE_EN) @@ -258,6 +258,9 @@ class CompilationErrorHandling(MessageCompilationTests): # po file contains wrong po formatting. with self.assertRaises(CommandError): call_command("compilemessages", locale=["ja"], verbosity=0) + # It should still fail a second time. + with self.assertRaises(CommandError): + call_command("compilemessages", locale=["ja"], verbosity=0) def test_msgfmt_error_including_non_ascii(self): # po file contains invalid msgstr content (triggers non-ascii error content). |
