Esempio n. 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,
        })
Esempio n. 2
0
def test_display_handle():
    ip = get_ipython()
    handle = display.DisplayHandle()
    assert isinstance(handle.display_id, str)
    handle = display.DisplayHandle("my-id")
    assert 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]
    assert args == ()
    assert kwargs == {
        'data': {
            'text/plain': repr('x')
        },
        'metadata': {},
        'transient': {
            'display_id': handle.display_id,
        }
    }
    args, kwargs = pub.call_args_list[1]
    assert args == ()
    assert kwargs == {
        'data': {
            'text/plain': repr('y')
        },
        'metadata': {},
        'transient': {
            'display_id': handle.display_id,
        },
        'update': True,
    }