MCPcopy
hub / github.com/django/django / test_no_write_access

Method test_no_write_access

tests/i18n/test_compilation.py:46–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

44 self.assertFalse(os.path.exists(self.MO_FILE))
45
46 def test_no_write_access(self):
47 mo_file_en = Path(self.MO_FILE_EN)
48 err_buffer = StringIO()
49 # Put parent directory in read-only mode.
50 old_mode = mo_file_en.parent.stat().st_mode
51 mo_file_en.parent.chmod(stat.S_IRUSR | stat.S_IXUSR)
52 # Ensure .po file is more recent than .mo file.
53 mo_file_en.with_suffix(".po").touch()
54 try:
55 with self.assertRaisesMessage(
56 CommandError, "compilemessages generated one or more errors."
57 ):
58 call_command(
59 "compilemessages", locale=["en"], stderr=err_buffer, verbosity=0
60 )
61 self.assertIn("not writable location", err_buffer.getvalue())
62 finally:
63 mo_file_en.parent.chmod(old_mode)
64
65 def test_no_compile_when_unneeded(self):
66 mo_file_en = Path(self.MO_FILE_EN)

Callers

nothing calls this directly

Calls 4

call_commandFunction · 0.90
assertRaisesMessageMethod · 0.80
touchMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected