Пример #1
0
 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)
Пример #2
0
    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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 def test_bad_io(self):
     expr = Expression(23)
     with assert_raises_str(AttributeError, "'int' object has no attribute 'write'"):
         expr.print_into(42)
Пример #7
0
 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)
Пример #8
0
 def test_bad_io(self):
     expr = Expression(23)
     with assert_raises_str(AttributeError,
                            "'int' object has no attribute 'write'"):
         expr.print_into(42)