예제 #1
0
def test_display_handle():
    ip = get_ipython()
    handle = display.DisplayHandle()
    nt.assert_is_instance(handle.display_id, str)
    handle = display.DisplayHandle('my-id')
    nt.assert_equal(handle.display_id, 'my-id')
    with mock.patch.object(ip.display_pub, 'publish') as pub:
        handle.display('x')
        handle.update('y')

    args, kwargs = pub.call_args_list[0]
    nt.assert_equal(args, ())
    nt.assert_equal(kwargs, {
        'data': {
            'text/plain': repr('x')
        },
        'metadata': {},
        'transient': {
            'display_id': handle.display_id,
        }
    })
    args, kwargs = pub.call_args_list[1]
    nt.assert_equal(args, ())
    nt.assert_equal(kwargs, {
        'data': {
            'text/plain': repr('y')
        },
        'metadata': {},
        'transient': {
            'display_id': handle.display_id,
        },
        'update': True,
    })
예제 #2
0
def test_display_handle():
    ip = get_ipython()
    handle = display.DisplayHandle()
    nt.assert_is_instance(handle.display_id, str)
    handle = display.DisplayHandle("my-id")
    nt.assert_equal(handle.display_id, "my-id")
    with mock.patch.object(ip.display_pub, "publish") as pub:
        handle.display("x")
        handle.update("y")

    args, kwargs = pub.call_args_list[0]
    nt.assert_equal(args, ())
    nt.assert_equal(
        kwargs,
        {
            "data": {
                "text/plain": repr("x")
            },
            "metadata": {},
            "transient": {
                "display_id": handle.display_id
            },
        },
    )
    args, kwargs = pub.call_args_list[1]
    nt.assert_equal(args, ())
    nt.assert_equal(
        kwargs,
        {
            "data": {
                "text/plain": repr("y")
            },
            "metadata": {},
            "transient": {
                "display_id": handle.display_id
            },
            "update": True,
        },
    )