Skip to content

Commit 1471551

Browse files
committed
refact(plot.TC): avoid writting multiple temp-files
1 parent 3fe0b40 commit 1471551

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

test/test_graphkit.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,35 @@ def test_plotting():
117117
inputs = {'a': 1, 'b1': 2}
118118
solution=pipeline(inputs)
119119

120-
# ...not working on my PC ...
121-
forbidden_formats = ".dia .hpgl .mif .mp .pcl .pic .vtx .xlib".split()
122120

121+
## Generate all formats
122+
# (not needing to save files)
123+
#
124+
# ...these are not working on my PC, or travis.
125+
forbidden_formats = ".dia .hpgl .mif .mp .pcl .pic .vtx .xlib".split()
126+
prev_dot = None
127+
for ext in network.supported_plot_formats():
128+
if ext in forbidden_formats:
129+
continue
130+
131+
dot = pipeline.plot(inputs=inputs, solution=solution, outputs=['asked', 'b1'])
132+
assert dot
133+
assert dot != prev_dot
134+
prev_dot = dot
135+
136+
dot = pipeline.plot()
137+
assert dot
138+
assert dot != prev_dot
139+
prev_dot = dot
140+
141+
## Try saving one file.
142+
#
123143
tdir = tempfile.mkdtemp()
124-
counter = 0
144+
fpath = osp.join(tdir, "workflow.png")
125145
try:
126-
for ext in network.supported_plot_formats():
127-
if ext in forbidden_formats:
128-
continue
129-
130-
counter += 1
131-
fpath = osp.join(tdir, "workflow-%i%s" % (counter, ext))
132-
pipeline.plot(fpath, inputs=inputs, solution=solution, outputs=['asked', 'b1'])
133-
assert osp.exists(fpath)
134-
135-
counter += 1
136-
fpath = osp.join(tdir, "workflow-%i%s" % (counter, ext))
137-
pipeline.plot(fpath)
138-
assert osp.exists(fpath)
146+
dot = pipeline.plot(fpath, inputs=inputs, solution=solution, outputs=['asked', 'b1'])
147+
assert osp.exists(fpath)
148+
assert dot
139149
finally:
140150
shutil.rmtree(tdir, ignore_errors=True)
141151

0 commit comments

Comments
 (0)