Beispiel #1
0
 def test_bad_file_io(self):
     if os.name == 'nt':
         raise SkipTest('not implemented on Windows')
     path = '/proc/self/mem'
     try:
         os.stat(path)
     except OSError as exc:
         raise SkipTest('{exc.filename}: {exc.strerror}'.format(exc=exc))
     with open('/proc/self/mem') as fp:
         with assert_raises(IOError) as ecm:
             Expression.from_stream(fp)
     assert_in(ecm.exception.errno, (errno.EIO, errno.EFAULT))
Beispiel #2
0
 def test_bad_file_io(self):
     if os.name == 'nt':
         raise SkipTest('not implemented on Windows')
     path = '/proc/self/mem'
     try:
         os.stat(path)
     except OSError as exc:
         raise SkipTest('{exc.filename}: {exc.strerror}'.format(exc=exc))
     with open('/proc/self/mem') as fp:
         with assert_raises(IOError) as ecm:
             Expression.from_stream(fp)
     assert_in(
         ecm.exception.errno,
         (errno.EIO, errno.EFAULT)
     )
Beispiel #3
0
 def read():
     return Expression.from_stream(fp)
Beispiel #4
0
 def test_bad_unicode_io(self):
     fp = StringIO(chr(0xD800))
     with assert_raises(UnicodeEncodeError):
         Expression.from_stream(fp)
Beispiel #5
0
 def test_bad_io(self):
     with assert_raises_str(AttributeError, "'int' object has no attribute 'read'"):
         Expression.from_stream(42)
Beispiel #6
0
 def read():
     return Expression.from_stream(fp)
Beispiel #7
0
 def test_bad_unicode_io(self):
     fp = StringIO(chr(0xD800))
     with assert_raises(UnicodeEncodeError):
         Expression.from_stream(fp)
Beispiel #8
0
 def test_bad_io(self):
     with assert_raises_str(AttributeError,
                            "'int' object has no attribute 'read'"):
         Expression.from_stream(42)