diff --git a/IPython/core/tests/test_events.py b/IPython/core/tests/test_events.py index a2ece35..dcf6775 100644 --- a/IPython/core/tests/test_events.py +++ b/IPython/core/tests/test_events.py @@ -1,6 +1,7 @@ from backcall import callback_prototype import unittest from unittest.mock import Mock +import nose.tools as nt from IPython.core import events import IPython.testing.tools as tt @@ -30,7 +31,18 @@ class CallbackTests(unittest.TestCase): 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) + nt.assert_raises(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)