| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
from pyrepl.historical_reader import HistoricalReader |
| 21 |
from .infrastructure import EA, BaseTestReader, sane_term, read_spec |
| 22 |
|
| 23 |
|
| 24 |
|
| 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) |