(self, with_timeout)
| 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) |
no test coverage detected