From 8dea3f6f0f38b7bddef91a2db9238837b0513ce3 2017-10-25 20:09:51 From: Thomas A Caswell Date: 2017-10-25 20:09:51 Subject: [PATCH] TST: add test for searching for removal with bare functions --- 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)