示例#1
0
def test_loading_a_image_from_url():
    """Tests the loading of a image from a url"""
    url = 'https://file-examples-com.github.io/uploads/2017/10/file_example_PNG_500kB.png'

    image_pane = PNG(url)
    image_data = image_pane._data()
    assert b'PNG' in image_data
示例#2
0
def test_loading_a_image_from_pathlib():
    """Tests the loading of a image from a pathlib"""
    filepath = Path(__file__).parent.parent / "test_data" / "logo.png"

    image_pane = PNG(filepath)
    image_data = image_pane._data()
    assert b'PNG' in image_data
示例#3
0
def test_loading_a_image_from_url():
    """Tests the loading of a image from a url"""
    url = 'https://raw.githubusercontent.com/holoviz/panel/master/doc/_static/logo.png'

    image_pane = PNG(url)
    image_data = image_pane._data()
    assert b'PNG' in image_data
示例#4
0
def test_image_from_bytes():
    path = os.path.dirname(__file__)
    with open(os.path.join(path, '../test_data/logo.png'), 'rb') as f:
        img = f.read()

    image_pane = PNG(img)
    image_data = image_pane._data()
    assert b'PNG' in image_data
示例#5
0
def test_load_from_stringio():
    """Testing a loading a image from a StringIO"""
    memory = StringIO()

    path = os.path.dirname(__file__)
    with open(os.path.join(path, '../test_data/logo.png'), 'rb') as image_file:
        memory.write(str(image_file.read()))

    image_pane = PNG(memory)
    image_data = image_pane._data()
    assert 'PNG' in image_data