From: Florent Xicluna Date: Sun, 8 Aug 2010 18:06:13 +0000 (+0000) Subject: Issue #7564: Skip test_ioctl if another process is attached to /dev/tty. X-Git-Tag: v3.2a2~418 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39d795d8c1a1b2feaff407a8d583eb2fc16f2475;p=python Issue #7564: Skip test_ioctl if another process is attached to /dev/tty. --- diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index 47e5911523..07dac09d86 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -7,9 +7,17 @@ get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature try: tty = open("/dev/tty", "r") - tty.close() except IOError: raise unittest.SkipTest("Unable to open /dev/tty") +else: + # Skip if another process is in foreground + r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") + tty.close() + rpgrp = struct.unpack("i", r)[0] + if rpgrp not in (os.getpgrp(), os.getsid(0)): + raise unittest.SkipTest("Neither the process group nor the session " + "are attached to /dev/tty") + del tty, r, rpgrp try: import pty diff --git a/Misc/NEWS b/Misc/NEWS index 318b826d21..c6795a249a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -136,6 +136,8 @@ Tools/Demos Tests ----- +- Issue #7564: Skip test_ioctl if another process is attached to /dev/tty. + - Issue #8433: Fix test_curses failure with newer versions of ncurses. - Issue #9496: Provide a test suite for the rlcompleter module. Patch by