|
1 | 1 | """Test that output from dotparsing and dot is the same""" |
2 | 2 |
|
3 | | -import re |
4 | 3 | import os |
5 | | -import shutil |
6 | 4 | import glob |
7 | | -import sys |
| 5 | +import subprocess |
8 | 6 | import time |
9 | 7 |
|
10 | 8 | from PIL import ImageChops, Image |
@@ -83,26 +81,26 @@ def get_testfiles(): |
83 | 81 | origpngfilename = join(PNG_DIR, basefilenamenoext + '.png') |
84 | 82 | newpngfilename = join(PNG_DIR, basefilenamenoext + '.new.png') |
85 | 83 | # create PNG from original dot file |
86 | | - syscmd = 'dot -Tpng %s > %s' % (dotfile, origpngfilename) |
| 84 | + syscmd = ['dot', '-Tpng', '%s > %s' % (dotfile, origpngfilename)] |
87 | 85 | 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: |
90 | 88 | log.warning("Failed to create original %s", origpngfilename) |
91 | 89 | failedfiles.append(basefilename) |
92 | 90 | continue |
93 | 91 | # create PNG from dot file generated by dotparsing |
94 | | - syscmd = 'dot -Tpng %s > %s' % (newfilename, newpngfilename) |
| 92 | + syscmd = ['dot', '-Tpng', '%s > %s' % (newfilename, newpngfilename)] |
95 | 93 | 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: |
98 | 96 | log.warning("Failed to create new %s", origpngfilename) |
99 | 97 | failedfiles.append(basefilename) |
100 | 98 | continue |
101 | 99 | # load and compare images |
102 | 100 | try: |
103 | 101 | imorig = Image.open(origpngfilename) |
104 | 102 | imnew = Image.open(newpngfilename) |
105 | | - except: |
| 103 | + except OSError: |
106 | 104 | log.exception('Could not load %s images', basefilename) |
107 | 105 | continue |
108 | 106 | if equal(imorig, imnew): |
|
0 commit comments