Refs #32144 -- Made makemessages remove temporary files on preprocessing error.
Co-authored-by: Anders Hovmöller <anders.hovmoller@dryft.se>
This commit is contained in:
parent
dfa7781033
commit
4af162d4de
|
@ -527,6 +527,11 @@ class Command(BaseCommand):
|
|||
)
|
||||
)
|
||||
continue
|
||||
except BaseException:
|
||||
# Cleanup before exit.
|
||||
for build_file in build_files:
|
||||
build_file.cleanup()
|
||||
raise
|
||||
build_files.append(build_file)
|
||||
|
||||
if self.domain == 'djangojs':
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% blocktranslate %}Hello{% endblocktranslate %}
|
||||
|
||||
This file has a name that should be lexicographically before
|
||||
'template_with_error.tpl' so that we can test the cleanup case
|
||||
of the first file being successful, but the second failing.
|
|
@ -226,8 +226,9 @@ class BasicExtractorTests(ExtractorTests):
|
|||
)
|
||||
with self.assertRaisesMessage(SyntaxError, msg):
|
||||
management.call_command('makemessages', locale=[LOCALE], extensions=['tpl'], verbosity=0)
|
||||
# The temporary file was cleaned up
|
||||
# The temporary files were cleaned up.
|
||||
self.assertFalse(os.path.exists('./templates/template_with_error.tpl.py'))
|
||||
self.assertFalse(os.path.exists('./templates/template_0_with_no_error.tpl.py'))
|
||||
|
||||
def test_unicode_decode_error(self):
|
||||
shutil.copyfile('./not_utf8.sample', './not_utf8.txt')
|
||||
|
|
Loading…
Reference in New Issue