cpython: aea58e1cae75 (original) (raw)
Mercurial > cpython
changeset 85624:aea58e1cae75
Issue #18904: test_os and test_socket use unittest.skipIf() to check if fcntl module is present (to record skipped tests) [#18904]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Sun, 08 Sep 2013 14:14:38 +0200 |
parents | 74dc664ad699 |
children | 138e086e187d 6d6d68c068ad |
files | Lib/test/test_os.py Lib/test/test_socket.py |
diffstat | 2 files changed, 44 insertions(+), 42 deletions(-)[+] [-] Lib/test/test_os.py 37 Lib/test/test_socket.py 49 |
line wrap: on
line diff
--- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -2312,28 +2312,29 @@ class FDInheritanceTests(unittest.TestCa os.set_inheritable(fd, True) self.assertEqual(os.get_inheritable(fd), True)
- if fcntl:
def test_get_inheritable_cloexec(self):[](#l1.8)
fd = os.open(__file__, os.O_RDONLY)[](#l1.9)
self.addCleanup(os.close, fd)[](#l1.10)
self.assertEqual(os.get_inheritable(fd), False)[](#l1.11)
- @unittest.skipIf(fcntl is None, "need fcntl")
- def test_get_inheritable_cloexec(self):
fd = os.open(__file__, os.O_RDONLY)[](#l1.14)
self.addCleanup(os.close, fd)[](#l1.15)
self.assertEqual(os.get_inheritable(fd), False)[](#l1.16)
# clear FD_CLOEXEC flag[](#l1.18)
flags = fcntl.fcntl(fd, fcntl.F_GETFD)[](#l1.19)
flags &= ~fcntl.FD_CLOEXEC[](#l1.20)
fcntl.fcntl(fd, fcntl.F_SETFD, flags)[](#l1.21)
# clear FD_CLOEXEC flag[](#l1.22)
flags = fcntl.fcntl(fd, fcntl.F_GETFD)[](#l1.23)
flags &= ~fcntl.FD_CLOEXEC[](#l1.24)
fcntl.fcntl(fd, fcntl.F_SETFD, flags)[](#l1.25)
self.assertEqual(os.get_inheritable(fd), True)[](#l1.27)
self.assertEqual(os.get_inheritable(fd), True)[](#l1.28)
def test_set_inheritable_cloexec(self):[](#l1.30)
fd = os.open(__file__, os.O_RDONLY)[](#l1.31)
self.addCleanup(os.close, fd)[](#l1.32)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l1.33)
fcntl.FD_CLOEXEC)[](#l1.34)
- @unittest.skipIf(fcntl is None, "need fcntl")
- def test_set_inheritable_cloexec(self):
fd = os.open(__file__, os.O_RDONLY)[](#l1.37)
self.addCleanup(os.close, fd)[](#l1.38)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l1.39)
fcntl.FD_CLOEXEC)[](#l1.40)
os.set_inheritable(fd, True)[](#l1.42)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l1.43)
0)[](#l1.44)
os.set_inheritable(fd, True)[](#l1.45)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l1.46)
0)[](#l1.47)
def test_open(self): fd = os.open(file, os.O_RDONLY)
--- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -4808,30 +4808,31 @@ class InheritanceTest(unittest.TestCase) sock.set_inheritable(False) self.assertEqual(sock.get_inheritable(), False)
- if fcntl:
def test_get_inheritable_cloexec(self):[](#l2.8)
sock = socket.socket()[](#l2.9)
with sock:[](#l2.10)
fd = sock.fileno()[](#l2.11)
self.assertEqual(sock.get_inheritable(), False)[](#l2.12)
# clear FD_CLOEXEC flag[](#l2.14)
flags = fcntl.fcntl(fd, fcntl.F_GETFD)[](#l2.15)
flags &= ~fcntl.FD_CLOEXEC[](#l2.16)
fcntl.fcntl(fd, fcntl.F_SETFD, flags)[](#l2.17)
self.assertEqual(sock.get_inheritable(), True)[](#l2.19)
def test_set_inheritable_cloexec(self):[](#l2.21)
sock = socket.socket()[](#l2.22)
with sock:[](#l2.23)
fd = sock.fileno()[](#l2.24)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l2.25)
fcntl.FD_CLOEXEC)[](#l2.26)
sock.set_inheritable(True)[](#l2.28)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l2.29)
0)[](#l2.30)
- @unittest.skipIf(fcntl is None, "need fcntl")
- def test_get_inheritable_cloexec(self):
sock = socket.socket()[](#l2.33)
with sock:[](#l2.34)
fd = sock.fileno()[](#l2.35)
self.assertEqual(sock.get_inheritable(), False)[](#l2.36)
# clear FD_CLOEXEC flag[](#l2.38)
flags = fcntl.fcntl(fd, fcntl.F_GETFD)[](#l2.39)
flags &= ~fcntl.FD_CLOEXEC[](#l2.40)
fcntl.fcntl(fd, fcntl.F_SETFD, flags)[](#l2.41)
self.assertEqual(sock.get_inheritable(), True)[](#l2.43)
- @unittest.skipIf(fcntl is None, "need fcntl")
- def test_set_inheritable_cloexec(self):
sock = socket.socket()[](#l2.47)
with sock:[](#l2.48)
fd = sock.fileno()[](#l2.49)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l2.50)
fcntl.FD_CLOEXEC)[](#l2.51)
sock.set_inheritable(True)[](#l2.53)
self.assertEqual(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC,[](#l2.54)
0)[](#l2.55)