Пример #1
0
def test_save_buttons():
    viewer = get_image_viewer()
    sv = SaveButtons()
    viewer.plugins[0] += sv

    import tempfile
    fid, filename = tempfile.mkstemp(suffix='.png')
    os.close(fid)

    timer = QtCore.QTimer()
    timer.singleShot(100, QtWidgets.QApplication.quit)

    # exercise the button clicks
    sv.save_stack.click()
    sv.save_file.click()

    # call the save functions directly
    sv.save_to_stack()
    with expected_warnings(['precision loss']):
        sv.save_to_file(filename)

    img = data.imread(filename)

    with expected_warnings(['precision loss']):
        assert_almost_equal(img, img_as_uint(viewer.image))

    img = io.pop()
    assert_almost_equal(img, viewer.image)

    os.remove(filename)
Пример #2
0
def test_save_buttons():
    viewer = get_image_viewer()
    sv = SaveButtons()
    viewer.plugins[0] += sv

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')
    os.remove(filename)

    timer = QtCore.QTimer()
    timer.singleShot(100, lambda: QtGui.QApplication.quit())

    sv.save_to_stack()
    sv.save_to_file(filename)

    img = img_as_float(data.imread(filename))
    assert_almost_equal(img, viewer.image)

    img = io.pop()
    assert_almost_equal(img, viewer.image)
Пример #3
0
def test_save_file_dialog():
    utils.init_qtapp()
    timer = QtCore.QTimer()
    timer.singleShot(100, lambda: QtGui.QApplication.quit())
    filename = dialogs.save_file_dialog()
    assert filename is None
Пример #4
0
def test_event_loop():
    utils.init_qtapp()
    timer = QtCore.QTimer()
    timer.singleShot(10, QtGui.QApplication.quit)
    utils.start_qtapp()
Пример #5
0
def test_open_file_dialog():
    QApp = utils.init_qtapp()
    timer = QtCore.QTimer()
    timer.singleShot(100, lambda: QApp.quit())
    filename = dialogs.open_file_dialog()
    assert filename is None
Пример #6
0
def test_open_file_dialog():
    utils.init_qtapp()
    timer = QtCore.QTimer()
    timer.singleShot(10, QtGui.QApplication.quit)
    filename = dialogs.open_file_dialog()
    assert filename is None