##// END OF EJS Templates
Warn about .py/.json collisions in config...
Warn about .py/.json collisions in config when two versions of the config file set the same value, warn about clobbering, with a message, such as: ``` [TerminalIPythonApp] WARNING | Collisions detected in ipython_config.py and ipython_config.json config files. ipython_config.json has higher priority: { "Klass": { "trait": "'python' ignored, using 'json'" } } ``` In anticipation of more machine-written .json config

File last commit:

r18547:4043b271
r19160:f22c8070
Show More
test_events.py
32 lines | 929 B | text/x-python | PythonLexer
Thomas Kluyver
Add tests for callback infrastructure
r15601 import unittest
try: # Python 3.3 +
from unittest.mock import Mock
except ImportError:
from mock import Mock
Thomas Kluyver
Rename callbacks -> events (mostly), fire -> trigger
r15605 from IPython.core import events
Thomas Kluyver
Add tests for callback infrastructure
r15601 import IPython.testing.tools as tt
def ping_received():
pass
class CallbackTests(unittest.TestCase):
def setUp(self):
Thomas Kluyver
Rename callbacks -> events (mostly), fire -> trigger
r15605 self.em = events.EventManager(get_ipython(), {'ping_received': ping_received})
Thomas Kluyver
Add tests for callback infrastructure
r15601
def test_register_unregister(self):
cb = Mock()
Thomas Kluyver
Rename callbacks -> events (mostly), fire -> trigger
r15605 self.em.register('ping_received', cb)
self.em.trigger('ping_received')
Thomas Kluyver
Add tests for callback infrastructure
r15601 self.assertEqual(cb.call_count, 1)
Thomas Kluyver
Rename callbacks -> events (mostly), fire -> trigger
r15605 self.em.unregister('ping_received', cb)
self.em.trigger('ping_received')
Thomas Kluyver
Add tests for callback infrastructure
r15601 self.assertEqual(cb.call_count, 1)
def test_cb_error(self):
cb = Mock(side_effect=ValueError)
Thomas Kluyver
Rename callbacks -> events (mostly), fire -> trigger
r15605 self.em.register('ping_received', cb)
Thomas Kluyver
Add tests for callback infrastructure
r15601 with tt.AssertPrints("Error in callback"):
Nathaniel J. Smith
Remove EventManager reset methods, because they violate encapsulation....
r18547 self.em.trigger('ping_received')