even less error emails and future proofing for test-utils
This commit is contained in:
Родитель
50624060e8
Коммит
1b909de3a9
|
@ -132,6 +132,13 @@ class FileViewer:
|
|||
UTF-8 and UTF-16 files appropriately. Return file contents and
|
||||
a list of error messages.
|
||||
"""
|
||||
try:
|
||||
return self._read_file(allow_empty)
|
||||
except (IOError, OSError):
|
||||
self.selected['msg'] = _('That file no longer exists.')
|
||||
return ''
|
||||
|
||||
def _read_file(self, allow_empty=False):
|
||||
if not self.selected and allow_empty:
|
||||
return ''
|
||||
assert self.selected, 'Please select a file'
|
||||
|
@ -141,12 +148,6 @@ class FileViewer:
|
|||
self.selected['msg'] = msg
|
||||
return ''
|
||||
|
||||
# Between the file data going into the cache and the file being
|
||||
# accessed, the individual file has been removed.
|
||||
if not os.path.exists(self.selected['full']):
|
||||
self.selected['msg'] = _('That file no longer exists.')
|
||||
return ''
|
||||
|
||||
with open(self.selected['full'], 'r') as opened:
|
||||
cont = opened.read()
|
||||
codec = 'utf-16' if cont.startswith(codecs.BOM_UTF16) else 'utf-8'
|
||||
|
|
|
@ -66,7 +66,7 @@ class FilesBase:
|
|||
# Setting this to True, so we are delaying the extraction of files,
|
||||
# in the tests, the files won't be extracted.
|
||||
# Most of these tests extract as needed to.
|
||||
Switch.objects.create(name='delay-file-viewer', active=True)
|
||||
Switch.objects.get_or_create(name='delay-file-viewer', active=True)
|
||||
|
||||
def tearDown(self):
|
||||
self.file_viewer.cleanup()
|
||||
|
|
Загрузка…
Ссылка в новой задаче