def test_reentrant(self): if not _ExpressionIO._reentrant: raise SkipTest('this test requires DjVuLibre >= 3.5.26') class File(object): def write(self, s): expr.as_string() expr = Expression(23) fp = File() expr.print_into(fp)
def test_bad_file_io(self): ecm = None path = '/dev/full' try: os.stat(path) except OSError as exc: raise SkipTest('{exc.filename}: {exc.strerror}'.format(exc=exc)) fp = open(path, 'w', buffering=2) expr = Expression(23) try: with assert_raises(IOError) as ecm: for i in range(10000): expr.print_into(fp) finally: try: fp.close() except IOError: if ecm is None: raise assert_equal(ecm.exception.errno, errno.ENOSPC)
def test_escape_unicode_type(self): expr = Expression(23) fp = StringIO() for v in True, False, 1, 0, 'yes', '': expr.print_into(fp, escape_unicode=v) expr.as_string(escape_unicode=v)
def test_bad_io(self): expr = Expression(23) with assert_raises_str(AttributeError, "'int' object has no attribute 'write'"): expr.print_into(42)