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

Method check_sendall_interrupted

Lib/test/test_socket.py:1783–1812  ·  view source on GitHub ↗
(self, with_timeout)

Source from the content-addressed store, hash-verified

1781 # socket.gethostbyaddr('испытание.python.org')
1782
1783 def check_sendall_interrupted(self, with_timeout):
1784 # socketpair() is not strictly required, but it makes things easier.
1785 if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'):
1786 self.skipTest("signal.alarm and socket.socketpair required for this test")
1787 # Our signal handlers clobber the C errno by calling a math function
1788 # with an invalid domain value.
1789 def ok_handler(*args):
1790 self.assertRaises(ValueError, math.acosh, 0)
1791 def raising_handler(*args):
1792 self.assertRaises(ValueError, math.acosh, 0)
1793 1 // 0
1794 c, s = socket.socketpair()
1795 old_alarm = signal.signal(signal.SIGALRM, raising_handler)
1796 try:
1797 if with_timeout:
1798 # Just above the one second minimum for signal.alarm
1799 c.settimeout(1.5)
1800 with self.assertRaises(ZeroDivisionError):
1801 signal.alarm(1)
1802 c.sendall(b"x" * support.SOCK_MAX_SIZE)
1803 if with_timeout:
1804 signal.signal(signal.SIGALRM, ok_handler)
1805 signal.alarm(1)
1806 self.assertRaises(TimeoutError, c.sendall,
1807 b"x" * support.SOCK_MAX_SIZE)
1808 finally:
1809 signal.alarm(0)
1810 signal.signal(signal.SIGALRM, old_alarm)
1811 c.close()
1812 s.close()
1813
1814 def test_sendall_interrupted(self):
1815 self.check_sendall_interrupted(False)

Calls 7

hasattrFunction · 0.85
skipTestMethod · 0.80
socketpairMethod · 0.45
settimeoutMethod · 0.45
assertRaisesMethod · 0.45
sendallMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected