MCPcopy Index your code
hub / github.com/RustPython/RustPython / _check_ioctl_mutate_len

Method _check_ioctl_mutate_len

Lib/test/test_ioctl.py:39–55  ·  view source on GitHub ↗
(self, nbytes=None)

Source from the content-addressed store, hash-verified

37 self.assertIn(rpgrp, ids)
38
39 def _check_ioctl_mutate_len(self, nbytes=None):
40 buf = array.array('i')
41 intsize = buf.itemsize
42 ids = (os.getpgrp(), os.getsid(0))
43 # A fill value unlikely to be in `ids`
44 fill = -12345
45 if nbytes is not None:
46 # Extend the buffer so that it is exactly `nbytes` bytes long
47 buf.extend([fill] * (nbytes // intsize))
48 self.assertEqual(len(buf) * intsize, nbytes) # sanity check
49 else:
50 buf.append(fill)
51 with open("/dev/tty", "rb") as tty:
52 r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, True)
53 rpgrp = buf[0]
54 self.assertEqual(r, 0)
55 self.assertIn(rpgrp, ids)
56
57 def test_ioctl_mutate(self):
58 self._check_ioctl_mutate_len()

Callers 3

test_ioctl_mutateMethod · 0.95

Calls 7

lenFunction · 0.85
ioctlMethod · 0.80
assertInMethod · 0.80
openFunction · 0.50
extendMethod · 0.45
assertEqualMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected