From 8420fe984acb7b23e8feb4e5d6a0e4d3da5e4eb1 Mon Sep 17 00:00:00 2001 From: HappyTreeBeard <34220817+HappyTreeBeard@users.noreply.github.com> Date: Thu, 23 May 2019 21:33:23 -0700 Subject: [PATCH] Fixed bug in unit test where temp file remained open when os.unlink was called (#832) --- pyqtgraph/exporters/tests/test_csv.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/exporters/tests/test_csv.py b/pyqtgraph/exporters/tests/test_csv.py index 15c6626e..d6da033b 100644 --- a/pyqtgraph/exporters/tests/test_csv.py +++ b/pyqtgraph/exporters/tests/test_csv.py @@ -1,5 +1,5 @@ """ -SVG export test +CSV export test """ from __future__ import division, print_function, absolute_import import pyqtgraph as pg @@ -33,8 +33,9 @@ def test_CSVExporter(): ex = pg.exporters.CSVExporter(plt.plotItem) ex.export(fileName=tempfilename) - r = csv.reader(open(tempfilename, 'r')) - lines = [line for line in r] + with open(tempfilename, 'r') as csv_file: + r = csv.reader(csv_file) + lines = [line for line in r] header = lines.pop(0) assert header == ['myPlot_x', 'myPlot_y', 'x0001', 'y0001', 'x0002', 'y0002']