This function loads a python file as a module (with no package), and then instantiates the class it must contain, and finally executes the run_test() method of the class (which the class may override, but which is defined in both of the testing base classes, WebTest and ImageCompara
(*args, **kwargs)
| 642 | # paraview or vtk web application service. |
| 643 | # ============================================================================= |
| 644 | def launch_web_test(*args, **kwargs): |
| 645 | """ |
| 646 | This function loads a python file as a module (with no package), and then |
| 647 | instantiates the class it must contain, and finally executes the run_test() |
| 648 | method of the class (which the class may override, but which is defined in |
| 649 | both of the testing base classes, WebTest and ImageComparatorBaseClass). |
| 650 | After the run_test() method finishes, this function will stop the web |
| 651 | server if required. This function expects some keyword arguments will be |
| 652 | present in order for it to complete it's task: |
| 653 | |
| 654 | kwargs['serverOpts']: An object containing all the parameters used |
| 655 | to start the web service. Some of them will be used in the test script |
| 656 | in order perform the test. For example, the port on which the server |
| 657 | was started will be required in order to connect to the server. |
| 658 | |
| 659 | kwargs['testScript']: The full path to the python file containing the |
| 660 | testing subclass. |
| 661 | """ |
| 662 | |
| 663 | serverOpts = None |
| 664 | testScriptFile = None |
| 665 | |
| 666 | # This is really the thing all test scripts will need: access to all |
| 667 | # the options used to start the server process. |
| 668 | if "serverOpts" in kwargs: |
| 669 | serverOpts = kwargs["serverOpts"] |
| 670 | # print 'These are the serverOpts we got: ' |
| 671 | # print serverOpts |
| 672 | |
| 673 | # Get the full path to the test script |
| 674 | if "testScript" in kwargs: |
| 675 | testScriptFile = kwargs["testScript"] |
| 676 | |
| 677 | testName = "unknown" |
| 678 | |
| 679 | # Check for a test file (python file) |
| 680 | if testScriptFile is None: |
| 681 | print("No test script file found, no test script will be run.") |
| 682 | test_fail(testName) |
| 683 | |
| 684 | # The test name will be generated from the python script name, so |
| 685 | # match and capture a bunch of contiguous characters which are |
| 686 | # not '.', '\', or '/', followed immediately by the string '.py'. |
| 687 | fnamePattern = re.compile("([^\.\/\\\]+)\.py") |
| 688 | fmatch = re.search(fnamePattern, testScriptFile) |
| 689 | if fmatch: |
| 690 | testName = fmatch.group(1) |
| 691 | else: |
| 692 | print( |
| 693 | "Unable to parse testScriptFile (" |
| 694 | + str(testScriptfile) |
| 695 | + "), no test will be run" |
| 696 | ) |
| 697 | test_fail(testName) |
| 698 | |
| 699 | # If we successfully got a test name, we are ready to try and run the test |
| 700 | if testName != "unknown": |
| 701 |
nothing calls this directly
no test coverage detected