2 from test_support
import TestSkipped
, run_unittest
7 raise TestSkipped("No fcntl or termios module")
8 if not hasattr(termios
,'TIOCGPGRP'):
9 raise TestSkipped("termios module doesn't have TIOCGPGRP")
11 class IoctlTests(unittest
.TestCase
):
14 tty
= open("/dev/tty", "r")
15 r
= fcntl
.ioctl(tty
, termios
.TIOCGPGRP
, " ")
16 self
.assertEquals(pgrp
, struct
.unpack("i", r
)[0])
18 def test_ioctl_mutate(self
):
20 buf
= array
.array('i', [0])
22 tty
= open("/dev/tty", "r")
23 r
= fcntl
.ioctl(tty
, termios
.TIOCGPGRP
, buf
, 1)
24 self
.assertEquals(r
, 0)
25 self
.assertEquals(pgrp
, buf
[0])
28 run_unittest(IoctlTests
)
30 if __name__
== "__main__":