[pypy-commit] pypy py3.5-noninherit: Fixes in the test of fcntl
arigo
pypy.commits at gmail.com
Sat Aug 27 10:19:41 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-noninherit
Changeset: r86600:3a692066a13f
Date: 2016-08-27 16:19 +0200
http://bitbucket.org/pypy/pypy/changeset/3a692066a13f/
Log: Fixes in the test of fcntl
diff --git a/pypy/module/fcntl/test/test_fcntl.py b/pypy/module/fcntl/test/test_fcntl.py
--- a/pypy/module/fcntl/test/test_fcntl.py
+++ b/pypy/module/fcntl/test/test_fcntl.py
@@ -32,7 +32,7 @@
f = open(self.tmp + "b", "w+")
- fcntl.fcntl(f, 1, 0)
+ original = fcntl.fcntl(f, 1, 0)
fcntl.fcntl(f, 1)
fcntl.fcntl(F(int(f.fileno())), 1)
raises(TypeError, fcntl.fcntl, "foo")
@@ -46,9 +46,16 @@
raises(ValueError, fcntl.fcntl, -1, 1, 0)
raises(ValueError, fcntl.fcntl, F(-1), 1, 0)
raises(ValueError, fcntl.fcntl, F(int(-1)), 1, 0)
- assert fcntl.fcntl(f, 1, 0) == 0
+ assert fcntl.fcntl(f, 1, 0) == original
assert fcntl.fcntl(f, 2, "foo") == b"foo"
- assert fcntl.fcntl(f, 2, memoryview(b"foo")) == b"foo"
+ assert fcntl.fcntl(f, 2, b"foo") == b"foo"
+
+ # This is supposed to work I think, but CPython 3.5 refuses it
+ # for reasons I don't understand:
+ # >>> _testcapi.getargs_s_hash(memoryview(b"foo"))
+ # TypeError: must be read-only bytes-like object, not memoryview
+ #
+ # assert fcntl.fcntl(f, 2, memoryview(b"foo")) == b"foo"
try:
os.O_LARGEFILE
@@ -202,7 +209,7 @@
raises(TypeError, fcntl.ioctl, "foo")
raises(TypeError, fcntl.ioctl, 0, "foo")
#raises(TypeError, fcntl.ioctl, 0, TIOCGPGRP, float(0))
- raises(TypeError, fcntl.ioctl, 0, TIOCGPGRP, 1, "foo")
+ raises(TypeError, fcntl.ioctl, 0, TIOCGPGRP, 1, "foo", "bar")
child_pid, mfd = pty.fork()
if child_pid == 0:
@@ -229,13 +236,13 @@
assert res == 0
assert buf.tostring() == expected
- exc = raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, memoryview(b'abc'), False)
- assert str(exc.value) == "ioctl requires a file or file descriptor, an integer and optionally an integer or buffer argument"
+ raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, (), False)
res = fcntl.ioctl(mfd, TIOCGPGRP, buf, False)
assert res == expected
- raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, "\x00\x00", True)
+ # xxx this fails on CPython 3.5, that's a minor bug
+ #raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, "\x00\x00", True)
res = fcntl.ioctl(mfd, TIOCGPGRP, "\x00\x00\x00\x00")
assert res == expected
More information about the pypy-commit
mailing list