def test_scale_bar_fail():
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_scale_bar(axis=0, pixel_width=40, um_width='20', y=2, text_offset=1, line_kwargs=(1,),
                        text_kwargs=None)
    assert 'line_kwargs should be a dictionary' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        m = Movie()
        m.add_scale_bar(axis=0, pixel_width=40, um_width='20', y=2, text_offset=1, line_kwargs={'color': 'blue'},
                        text_kwargs=[2])
    assert 'text_kwargs should be a dictionary' in str(ex.value)
def test_scale_bar_kwargs():
    m = Movie()
    m.add_scale_bar(text_kwargs={'color': 'blue'}, line_kwargs={'color': 'blue'})
    line = m.annotations[0]
    assert line['axis'] == 0
    assert line['x'] == (0, 40)
    assert line['y'] == (2, 2)
    line_kwargs = line['kwargs']
    assert line_kwargs['color'] == 'blue'

    text = m.annotations[1]
    assert text['axis'] == 0
    assert text['x'] == 20
    assert text['y'] == 1
    assert text['text'] == '20um'
    text_kwargs = text['kwargs']
    assert text_kwargs['color'] == 'blue'
def test_scale_bar_default():
    m = Movie()
    m.add_scale_bar()
    line = m.annotations[0]
    assert line['axis'] == 0
    assert line['x'] == (0, 40)
    assert line['y'] == (2, 2)
    line_kwargs = line['kwargs']
    assert line_kwargs['color'] == 'white'
    assert line_kwargs['lw'] == 3

    text = m.annotations[1]
    assert text['axis'] == 0
    assert text['x'] == 20
    assert text['y'] == 1
    assert text['text'] == '20um'
    text_kwargs = text['kwargs']
    assert text_kwargs['ha'] == 'center'
    assert text_kwargs['fontsize'] == 14
    assert text_kwargs['color'] == 'white'