##// END OF EJS Templates
`AssertionError`: `assert _xterm_term_title_saved` in WSL (#14480)...
`AssertionError`: `assert _xterm_term_title_saved` in WSL (#14480) `AssertionError`: `assert _xterm_term_title_saved` In some (unknown) situation, it is possible that the `_xterm_term_title_saved` is unset, but the code would make a call to `_restore_term_title_xterm`, resulting in `AssertionError`. At least on replicatable reproduction is returning from `ipython` to `pudb` via `^D^D` on an empty cell. See more details in https://github.com/ipython/ipython/pull/14480 Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com> <details> <summary><em>was:</em></summary> In some (unknown) situation, it is possible that the `_xterm_term_title_saved` is unset, but the code would make a call to `_restore_term_title_xterm`, resulting in `AssertionError`. As title stacking does not seem to be getting traction (https://github.com/microsoft/terminal/issues/14575), do not set the `xterm` variants of `_set_term_title` / `_restore_term_title`. WSL detection: https://superuser.com/a/1749811/533196 Additionally, almost-`black` the file. </details>

File last commit:

r28469:1a8be18f
r28838:9b8cd4a3 merge
Show More
test_events.py
78 lines | 2.2 KiB | text/x-python | PythonLexer
import unittest
from unittest.mock import Mock
from IPython.core import events
import IPython.testing.tools as tt
@events._define_event
def ping_received():
pass
@events._define_event
def event_with_argument(argument):
pass
class CallbackTests(unittest.TestCase):
def setUp(self):
self.em = events.EventManager(get_ipython(),
{'ping_received': ping_received,
'event_with_argument': event_with_argument})
def test_register_unregister(self):
cb = Mock()
self.em.register('ping_received', cb)
self.em.trigger('ping_received')
self.assertEqual(cb.call_count, 1)
self.em.unregister('ping_received', cb)
self.em.trigger('ping_received')
self.assertEqual(cb.call_count, 1)
def test_bare_function_missed_unregister(self):
def cb1():
...
def cb2():
...
self.em.register("ping_received", cb1)
self.assertRaises(ValueError, self.em.unregister, "ping_received", cb2)
self.em.unregister("ping_received", cb1)
def test_cb_error(self):
cb = Mock(side_effect=ValueError)
self.em.register('ping_received', cb)
with tt.AssertPrints("Error in callback"):
self.em.trigger('ping_received')
def test_cb_keyboard_interrupt(self):
cb = Mock(side_effect=KeyboardInterrupt)
self.em.register('ping_received', cb)
with tt.AssertPrints("Error in callback"):
self.em.trigger('ping_received')
def test_unregister_during_callback(self):
invoked = [False] * 3
def func1(*_):
invoked[0] = True
self.em.unregister('ping_received', func1)
self.em.register('ping_received', func3)
def func2(*_):
invoked[1] = True
self.em.unregister('ping_received', func2)
def func3(*_):
invoked[2] = True
self.em.register('ping_received', func1)
self.em.register('ping_received', func2)
self.em.trigger('ping_received')
self.assertEqual([True, True, False], invoked)
self.assertEqual([func3], self.em.callbacks['ping_received'])