Commit 509c1d66 authored by Jason Madden's avatar Jason Madden

Debugging for a weird EPERM error in test__fileobject.py on travis with libuv;...

Debugging for a weird EPERM error in test__fileobject.py on travis with libuv; not seen locally or on appveyor [skip appveyor].
parent f173686c
......@@ -130,3 +130,9 @@ class FileObjectBase(object):
def _extra_repr(self):
return ''
def __enter__(self):
return self
def __exit__(self, *args):
self.close()
......@@ -53,7 +53,9 @@ class libuv_error_wrapper(object):
raise UVFuncallError(
str(ffi.string(libuv.uv_err_name(res)).decode('ascii')
+ ' '
+ ffi.string(libuv.uv_strerror(res)).decode('ascii')))
+ ffi.string(libuv.uv_strerror(res)).decode('ascii'))
+ "Args: " + repr(args) + "KWARGS: " + repr(kwargs)
)
return res
setattr(self, name, wrap)
......
......@@ -88,30 +88,30 @@ class Test(greentest.TestCase):
g.kill()
def test_seek(self):
fileno, path = tempfile.mkstemp()
fileno, path = tempfile.mkstemp('.gevent.test__fileobject.test_seek')
self.addCleanup(os.remove, path)
s = b'a' * 1024
os.write(fileno, b'B' * 15)
os.write(fileno, s)
os.close(fileno)
try:
with open(path, 'rb') as f:
f.seek(15)
native_data = f.read(1024)
with open(path, 'rb') as f_raw:
f = FileObject(f_raw, 'rb')
if hasattr(f, 'seekable'):
# Py3
self.assertTrue(f.seekable())
f.seek(15)
self.assertEqual(15, f.tell())
fileobj_data = f.read(1024)
self.assertEqual(native_data, s)
self.assertEqual(native_data, fileobj_data)
finally:
os.remove(path)
with open(path, 'rb') as f:
f.seek(15)
native_data = f.read(1024)
with open(path, 'rb') as f_raw:
print("Opened", f_raw)
f = FileObject(f_raw, 'rb')
if hasattr(f, 'seekable'):
# Py3
self.assertTrue(f.seekable())
f.seek(15)
self.assertEqual(15, f.tell())
fileobj_data = f.read(1024)
self.assertEqual(native_data, s)
self.assertEqual(native_data, fileobj_data)
def test_close_pipe(self):
# Issue #190, 203
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment