(self)
| 1725 | self.assertNotIn("4", stdout) |
| 1726 | |
| 1727 | def test_stdout_callback_kill(self): |
| 1728 | import signal |
| 1729 | |
| 1730 | py = create_tmp_test( |
| 1731 | """ |
| 1732 | import sys |
| 1733 | import os |
| 1734 | import time |
| 1735 | |
| 1736 | for i in range(5): |
| 1737 | print(i) |
| 1738 | time.sleep(.5) |
| 1739 | """ |
| 1740 | ) |
| 1741 | |
| 1742 | stdout = [] |
| 1743 | |
| 1744 | def agg(line, stdin, process): |
| 1745 | line = line.strip() |
| 1746 | stdout.append(line) |
| 1747 | if line == "3": |
| 1748 | process.kill() |
| 1749 | return True |
| 1750 | |
| 1751 | import sh |
| 1752 | |
| 1753 | caught_signal = False |
| 1754 | p = python("-u", py.name, _out=agg, _bg=True) |
| 1755 | try: |
| 1756 | p.wait() |
| 1757 | except sh.SignalException_SIGKILL: |
| 1758 | caught_signal = True |
| 1759 | |
| 1760 | self.assertTrue(caught_signal) |
| 1761 | self.assertEqual(p.process.exit_code, -signal.SIGKILL) |
| 1762 | self.assertNotIn("4", p) |
| 1763 | self.assertNotIn("4", stdout) |
| 1764 | |
| 1765 | def test_general_signal(self): |
| 1766 | from signal import SIGINT |
nothing calls this directly
no test coverage detected