Debian Codegraph @

extra_tests/test_pyrepl/test_bugs.py

raw symbols SCIP
1 # Copyright 2000-2004 Michael Hudson-Doyle <[email protected]>
2 #
3 # All Rights Reserved
4 #
5 #
6 # Permission to use, copy, modify, and distribute this software and
7 # its documentation for any purpose is hereby granted without fee,
8 # provided that the above copyright notice appear in all copies and
9 # that both that copyright notice and this permission notice appear in
10 # supporting documentation.
11 #
12 # THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
13 # THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 # AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
15 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
16 # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
17 # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 from pyrepl.historical_reader import HistoricalReader
21 from .infrastructure import EA, BaseTestReader, sane_term, read_spec
22
23 # this test case should contain as-verbatim-as-possible versions of
24 # (applicable) bug reports
25
26 import pytest
27
28
29 class HistoricalTestReader(HistoricalReader, BaseTestReader):
30 pass
31
32
33 @pytest.mark.xfail(reason='event missing', run=False)
34 def test_transpose_at_start():
35 read_spec([
36 ('transpose', [EA, '']),
37 ('accept', [''])])
38
39
40 def test_cmd_instantiation_crash():
41 spec = [
42 ('reverse-history-isearch', ["(r-search `') "]),
43 (('key', 'left'), ['']),
44 ('accept', [''])
45 ]
46 read_spec(spec, HistoricalTestReader)
47
48
49 @pytest.mark.skipif("os.name != 'posix' or 'darwin' in sys.platform or "
50 "'kfreebsd' in sys.platform")
51 def test_signal_failure(monkeypatch):
52 import os
53 import pty
54 import signal
55 from pyrepl.unix_console import UnixConsole
56
57 def failing_signal(a, b):
58 raise ValueError
59
60 def really_failing_signal(a, b):
61 raise AssertionError
62
63 mfd, sfd = pty.openpty()
64 try:
65 with sane_term():
66 c = UnixConsole(sfd, sfd)
67 c.prepare()
68 c.restore()
69 monkeypatch.setattr(signal, 'signal', failing_signal)
70 c.prepare()
71 monkeypatch.setattr(signal, 'signal', really_failing_signal)
72 c.restore()
73 finally:
74 os.close(mfd)
75 os.close(sfd)