File: test_image.py

package info (click to toggle)
python-pyqtgraph 0.13.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,072 kB
  • sloc: python: 54,043; makefile: 127; ansic: 40; sh: 2
file content (30 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np

import pyqtgraph as pg
import pyqtgraph.functions as fn
from pyqtgraph.exporters import ImageExporter
from pyqtgraph.Qt import QtGui

app = pg.mkQApp()


def test_ImageExporter_filename_dialog():
    """Tests ImageExporter code path that opens a file dialog. Regression test
    for pull request 1133."""
    p = pg.PlotWidget()
    p.show()
    exp = ImageExporter(p.getPlotItem())
    exp.export()


def test_ImageExporter_toBytes():
    p = pg.PlotWidget()
    p.show()
    p.hideAxis('bottom')
    p.hideAxis('left')
    exp = ImageExporter(p.getPlotItem())
    qimg = exp.export(toBytes=True)
    qimg = qimg.convertToFormat(QtGui.QImage.Format.Format_RGBA8888)
    data = fn.ndarray_from_qimage(qimg)
    black = (0, 0, 0, 255)
    assert np.all(data == black), "Exported image should be entirely black."