mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 07:46:30 +01:00
Tests for batchprocessors error conditions.
This commit is contained in:
parent
9154e477ef
commit
903bf1663e
2 changed files with 22 additions and 1 deletions
|
|
@ -233,7 +233,7 @@ def read_batchfile(pythonpath, file_ending=".py"):
|
|||
continue
|
||||
break
|
||||
if not text and decoderr:
|
||||
raise UnicodeDecodeError("\n".join(decoderr))
|
||||
raise UnicodeDecodeError("\n".join(decoderr), bytearray(), 0, 0, '')
|
||||
|
||||
return text
|
||||
|
||||
|
|
|
|||
21
evennia/utils/tests/test_batchprocessors.py
Normal file
21
evennia/utils/tests/test_batchprocessors.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"""Tests for batchprocessors """
|
||||
|
||||
import codecs
|
||||
from django.test import TestCase
|
||||
from evennia.utils import batchprocessors, utils
|
||||
import mock
|
||||
|
||||
|
||||
class TestBatchprocessorErrors(TestCase):
|
||||
|
||||
@mock.patch.object(utils, 'pypath_to_realpath', return_value=[])
|
||||
def test_read_batchfile_raises_IOError(self, _):
|
||||
with self.assertRaises(IOError):
|
||||
batchprocessors.read_batchfile('foopath')
|
||||
|
||||
@mock.patch.object(utils, 'pypath_to_realpath', return_value=['pathfoo'])
|
||||
@mock.patch.object(codecs, 'open', side_effect=ValueError('decodeerr'))
|
||||
@mock.patch.object(batchprocessors, '_ENCODINGS', ['fooencoding'])
|
||||
def test_read_batchfile_raises_UnicodeDecodeError(self, *_):
|
||||
with self.assertRaises(UnicodeDecodeError, msg='decodeerr'):
|
||||
batchprocessors.read_batchfile('foopath')
|
||||
Loading…
Add table
Add a link
Reference in a new issue