From 4e4a826d9debb88b40f3567391061e8f66767f69 2015-01-26 19:33:06 From: Min RK Date: 2015-01-26 19:33:06 Subject: [PATCH] test widget link argument validation --- diff --git a/IPython/html/widgets/tests/test_link.py b/IPython/html/widgets/tests/test_link.py new file mode 100644 index 0000000..24fbf07 --- /dev/null +++ b/IPython/html/widgets/tests/test_link.py @@ -0,0 +1,39 @@ +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + +import nose.tools as nt + +from .. import link, dlink, ToggleButton +from .test_interaction import setup, teardown + +def test_link_args(): + with nt.assert_raises(TypeError): + link() + w1 = ToggleButton() + with nt.assert_raises(TypeError): + link((w1, 'value')) + + w2 = ToggleButton() + link((w1, 'value'), (w2, 'value')) + + with nt.assert_raises(TypeError): + link((w1, 'value'), (w2, 'nosuchtrait')) + + with nt.assert_raises(TypeError): + link((w1, 'value'), (w2, 'traits')) + +def test_dlink_args(): + with nt.assert_raises(TypeError): + dlink() + w1 = ToggleButton() + with nt.assert_raises(TypeError): + dlink((w1, 'value')) + + w2 = ToggleButton() + dlink((w1, 'value'), (w2, 'value')) + + with nt.assert_raises(TypeError): + dlink((w1, 'value'), (w2, 'nosuchtrait')) + + with nt.assert_raises(TypeError): + dlink((w1, 'value'), (w2, 'traits'))