|
12 | 12 | import re |
13 | 13 | import sys |
14 | 14 | import logging |
| 15 | +import vcs |
15 | 16 |
|
16 | 17 | defaultThreshold=10.0 |
17 | 18 |
|
| 19 | +def init(*args, **kwargs): |
| 20 | + testingDir = os.path.join(os.path.dirname(__file__), "..") |
| 21 | + sys.path.append(testingDir) |
| 22 | + |
| 23 | + vcsinst = vcs.init(*args, **kwargs) |
| 24 | + vcsinst.setantialiasing(0) |
| 25 | + vcsinst.drawlogooff() |
| 26 | + |
| 27 | + if ('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs): |
| 28 | + vcsinst.setbgoutputdimensions(1200, 1091, units="pixels") |
| 29 | + return vcsinst |
| 30 | + |
| 31 | +def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): |
| 32 | + """Export plot to a png and exit after comparsion.""" |
| 33 | + vcsinst.png(fname) |
| 34 | + sys.exit(check_result_image(fname, baseline, threshold)) |
| 35 | + |
| 36 | +def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold): |
| 37 | + """Export plot to a png and return comparison with baseline.""" |
| 38 | + vcsinst.png(fname) |
| 39 | + return check_result_image(fname, baseline, threshold) |
| 40 | + |
18 | 41 | def image_compare(testImage, baselineImage): |
19 | 42 | imageDiff = vtk.vtkImageDifference() |
20 | 43 | imageDiff.SetInputData(testImage) |
@@ -53,8 +76,8 @@ def find_alternates(fname): |
53 | 76 | results.append(os.path.join(dirname, i)) |
54 | 77 | return results |
55 | 78 |
|
56 | | -def check_result_image(fname, baselinefname, threshold = defaultThreshold, |
57 | | - baseline = True, cleanup=True): |
| 79 | +def check_result_image(fname, baselinefname=sys.argv[1], threshold=defaultThreshold, |
| 80 | + baseline=True, cleanup=True): |
58 | 81 | testImage = image_from_file(fname) |
59 | 82 | if testImage is None: |
60 | 83 | print "Testing image missing, test failed." |
@@ -119,6 +142,7 @@ def printDart(name, type, value, suff=""): |
119 | 142 | printDart("ValidImage", "image/png", os.path.abspath(bestFilename), "File") |
120 | 143 | return -1 |
121 | 144 |
|
| 145 | + |
122 | 146 | def main(): |
123 | 147 | if len(sys.argv) != 4: |
124 | 148 | print "Error:" |
|
0 commit comments