Skip to content

Commit 567d430

Browse files
authored
Merge pull request #126 from fchapoton/exp_test3
using subprocess in exp. tests
2 parents a389fe8 + d592c65 commit 567d430

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

tests/experimental/test_graphparsing.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""Test that output from dotparsing and dot is the same"""
22

3-
import re
43
import os
5-
import shutil
64
import glob
7-
import sys
5+
import subprocess
86
import time
97

108
from PIL import ImageChops, Image
@@ -83,26 +81,26 @@ def get_testfiles():
8381
origpngfilename = join(PNG_DIR, basefilenamenoext + '.png')
8482
newpngfilename = join(PNG_DIR, basefilenamenoext + '.new.png')
8583
# create PNG from original dot file
86-
syscmd = 'dot -Tpng %s > %s' % (dotfile, origpngfilename)
84+
syscmd = ['dot', '-Tpng', '%s > %s' % (dotfile, origpngfilename)]
8785
log.debug("Run %s", syscmd)
88-
err = os.system(syscmd)
89-
if err:
86+
result = subprocess.run(syscmd, text=True, capture_output=True)
87+
if result.returncode:
9088
log.warning("Failed to create original %s", origpngfilename)
9189
failedfiles.append(basefilename)
9290
continue
9391
# create PNG from dot file generated by dotparsing
94-
syscmd = 'dot -Tpng %s > %s' % (newfilename, newpngfilename)
92+
syscmd = ['dot', '-Tpng', '%s > %s' % (newfilename, newpngfilename)]
9593
log.debug("Run %s", syscmd)
96-
err = os.system(syscmd)
97-
if err:
94+
result = subprocess.run(syscmd, text=True, capture_output=True)
95+
if result.returncode:
9896
log.warning("Failed to create new %s", origpngfilename)
9997
failedfiles.append(basefilename)
10098
continue
10199
# load and compare images
102100
try:
103101
imorig = Image.open(origpngfilename)
104102
imnew = Image.open(newpngfilename)
105-
except:
103+
except OSError:
106104
log.exception('Could not load %s images', basefilename)
107105
continue
108106
if equal(imorig, imnew):

0 commit comments

Comments
 (0)