MCPcopy Create free account
hub / github.com/Kitware/VTK / main

Function main

Wrapping/Python/vtkmodules/test/rtImageTest.py:25–130  ·  view source on GitHub ↗

Run a regression test, and compare the contents of the window against against a valid image. This will use arguments from sys.argv to set the testing options via the vtkTesting class, run the test script, and then call vtkTesting.RegressionTest() to validate the image. The return v

(test_script)

Source from the content-addressed store, hash-verified

23 return None
24
25def main(test_script):
26 """Run a regression test, and compare the contents of the window against
27 against a valid image. This will use arguments from sys.argv to set the
28 testing options via the vtkTesting class, run the test script, and then
29 call vtkTesting.RegressionTest() to validate the image. The return
30 value will the one provided by vtkTesting.RegressionTest().
31 """
32
33 # find the first argument that's an option
34 opt1 = 1
35 while opt1 < len(sys.argv) and not sys.argv[opt1].startswith('-'):
36 opt1 += 1
37
38 # get the "-A" option, which isn't handled by vtkTester
39 for i in range(opt1, len(sys.argv)):
40 if sys.argv[i] == '-A' and i < len(sys.argv) - 1:
41 sys.path.append(sys.argv[i + 1])
42
43 # create the testing class to do the work
44 rtTester = vtkTesting()
45
46 try:
47 rtTester.SetController(_GetController())
48 except:
49 pass
50
51 for arg in sys.argv[opt1:]:
52 rtTester.AddArgument(arg)
53
54 # if test is not interactive, make a mock interactor with a
55 # disabled Start method
56 if rtTester.IsInteractiveModeSpecified() == 0:
57 from vtkmodules.vtkRenderingCore import vtkRenderWindowInteractor
58 import vtkmodules.vtkRenderingUI
59 irenType = type(vtkRenderWindowInteractor())
60 class vtkTestingInteractor(irenType):
61 def Start(self):
62 pass
63 irenType.override(vtkTestingInteractor)
64
65 # seed the random number generator
66 vtkMath.RandomSeed(6)
67
68 # read the test script
69 with open(test_script) as test_file:
70 test_code = test_file.read()
71
72 # inject the test script's directory into sys.path
73 test_script_dir = os.path.abspath(os.path.dirname(test_script))
74 sys.path.insert(0, test_script_dir)
75
76 # we provide an initial set of variables for the test script
77 test_script_vars = { "__name__" : "__main__" }
78
79 try:
80 # run the test and capture all of its global variables
81 exec(compile(test_code, test_script, 'exec'), test_script_vars)
82 except Exception:

Callers 1

rtImageTest.pyFile · 0.70

Calls 15

compileFunction · 0.85
searchMethod · 0.80
IsValidImageSpecifiedMethod · 0.80
_GetControllerFunction · 0.70
RenderMethod · 0.65
rangeClass · 0.50
typeEnum · 0.50
appendMethod · 0.45
SetControllerMethod · 0.45
AddArgumentMethod · 0.45

Tested by

no test coverage detected