Catch and Address Warnings in test_svg and pytest.ini

On Windows, pyreadline is emitting a deprecation warning we can ignore.
Furthermore, test_svg was using NamedTemporaryFile in a manner that was
causing permission denied errors, so this commit switches to the use of
pytest friendly temporary files
This commit is contained in:
Ogi Moore 2021-05-29 22:54:07 -07:00
parent d859cec95a
commit d72be799d7
2 changed files with 9 additions and 17 deletions

View File

@ -19,3 +19,5 @@ filterwarnings =
ignore:Visible window deleted. To prevent this, store a reference to the window object.
# xvfb warnings on non-linux systems
ignore:Unknown config option:pytest.PytestConfigWarning
# pyreadline windows warning
ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working:DeprecationWarning:pyreadline:8

View File

@ -1,18 +1,10 @@
"""
SVG export test
"""
from __future__ import division, print_function, absolute_import
import pyqtgraph as pg
import tempfile
import os
app = pg.mkQApp()
def test_plotscene():
tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name
print("using %s as a temporary file" % tempfilename)
def test_plotscene(tmpdir):
pg.setConfigOption('foreground', (0,0,0))
w = pg.GraphicsLayoutWidget()
w.show()
@ -25,15 +17,13 @@ def test_plotscene():
app.processEvents()
ex = pg.exporters.SVGExporter(w.scene())
ex.export(fileName=tempfilename)
tf = tmpdir.join("expot.svg")
ex.export(fileName=tf)
# clean up after the test is done
os.unlink(tempfilename)
w.close()
def test_simple():
tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name
print("using %s as a temporary file" % tempfilename)
def test_simple(tmpdir):
view = pg.GraphicsView()
view.show()
@ -78,5 +68,5 @@ def test_simple():
grp2.addItem(rect3)
ex = pg.exporters.SVGExporter(scene)
ex.export(fileName=tempfilename)
os.unlink(tempfilename)
tf = tmpdir.join("expot.svg")
ex.export(fileName=tf)