"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test_suite/test_suite_runner.py" between
relax-4.1.3.src.tar.bz2 and relax-5.0.0.src.tar.bz2

About: relax allows the study of molecular dynamics through the analysis of experimental NMR data. Organic molecules, proteins, RNA, DNA, sugars, and other biomolecules are all supported.

test_suite_runner.py  (relax-4.1.3.src.tar.bz2):test_suite_runner.py  (relax-5.0.0.src.tar.bz2)
skipping to change at line 62 skipping to change at line 62
class Test_suite_runner: class Test_suite_runner:
"""Class for running all components of the relax test suite. """Class for running all components of the relax test suite.
This currently includes the following categories of tests: This currently includes the following categories of tests:
- System/functional tests. - System/functional tests.
- Unit tests. - Unit tests.
- GUI tests. - GUI tests.
- Verification tests. - Verification tests.
""" """
def __init__(self, tests=[], from_gui=False, categories=['system', 'unit', ' gui', 'verification'], timing=False): def __init__(self, tests=[], from_gui=False, categories=['system', 'unit', ' gui', 'verification'], timing=False, io_capture=True, list_tests=False):
"""Store the list of tests to preform. """Store the list of tests to preform.
The test list should be something like ['N_state_model.test_stereochem_a nalysis']. The first part is the imported test case class, the second is the sp ecific test. The test list should be something like ['N_state_model.test_stereochem_a nalysis']. The first part is the imported test case class, the second is the sp ecific test.
@keyword tests: The list of tests to preform. If left at [], th en all tests will be run. @keyword tests: The list of tests to preform. If left at [], th en all tests will be run.
@type tests: list of str @type tests: list of str
@keyword from_gui: A flag which indicates if the tests are being ru n from the GUI or not. @keyword from_gui: A flag which indicates if the tests are being ru n from the GUI or not.
@type from_gui: bool @type from_gui: bool
@keyword categories: The list of test categories to run, for example ['system', 'unit', 'gui', 'verification'] for all tests. @keyword categories: The list of test categories to run, for example ['system', 'unit', 'gui', 'verification'] for all tests.
@type categories: list of str @type categories: list of str
@keyword timing: A flag which if True will enable timing of indiv idual tests. @keyword timing: A flag which if True will enable timing of indiv idual tests.
@type timing: bool @type timing: bool
@keyword io_capture: A flag which if True will cause all IO to be cap
tured and only printed out for failing or error tests.
@type io_capture: bool
@keyword list_tests: A flag which if True will cause the tests to be
listed rather than executed.
@type list_tests: bool
""" """
# Store the args. # Store the args.
self.tests = tests self.tests = tests
self.from_gui = from_gui self.from_gui = from_gui
self.categories = categories self.categories = categories
self.list_tests = list_tests
# Set up the test runner. # Set up the test runner.
if from_gui: if from_gui:
self.runner = GuiTestRunner(stream=sys.stdout, timing=timing) self.runner = GuiTestRunner(stream=sys.stdout, timing=timing, io_cap ture=io_capture)
else: else:
self.runner = RelaxTestRunner(stream=sys.stdout, timing=timing) self.runner = RelaxTestRunner(stream=sys.stdout, timing=timing, io_c apture=io_capture)
# Let the tests handle the keyboard interrupt (for Python 2.7 and higher ). # Let the tests handle the keyboard interrupt (for Python 2.7 and higher ).
if hasattr(unittest, 'installHandler'): if hasattr(unittest, 'installHandler'):
unittest.installHandler() unittest.installHandler()
def run_all_tests(self, reset=True): def run_all_tests(self, reset=True):
"""Execute all of the test suite test types. """Execute all of the test suite test types.
@keyword reset: A flag which if True will reset the relax status obj ects for the tests. @keyword reset: A flag which if True will reset the relax status obj ects for the tests.
@type reset: bool @type reset: bool
skipping to change at line 125 skipping to change at line 130
# Execute the GUI tests. # Execute the GUI tests.
if 'gui' in self.categories: if 'gui' in self.categories:
test_status = self.run_gui_tests(summary=False, reset=False) and tes t_status test_status = self.run_gui_tests(summary=False, reset=False) and tes t_status
# Execute the software verification tests. # Execute the software verification tests.
if 'verification' in self.categories: if 'verification' in self.categories:
test_status = self.run_verification_tests(summary=False, reset=False ) and test_status test_status = self.run_verification_tests(summary=False, reset=False ) and test_status
# Print out a summary of the test suite and return the combined status. # Print out a summary of the test suite and return the combined status.
self.summary() if not self.list_tests:
self.summary()
return test_status return test_status
def run_gui_tests(self, summary=True, reset=True): def run_gui_tests(self, summary=True, reset=True):
"""Execute the GUI tests. """Execute the GUI tests.
@keyword summary: A flag which if True will cause a summary to be prin ted. @keyword summary: A flag which if True will cause a summary to be prin ted.
@type summary: bool @type summary: bool
@keyword reset: A flag which if True will reset the relax status obj ects for the tests. @keyword reset: A flag which if True will reset the relax status obj ects for the tests.
@type reset: bool @type reset: bool
@return: True if the tests were run, False if a KeyboardInter rupt occurred. @return: True if the tests were run, False if a KeyboardInter rupt occurred.
skipping to change at line 162 skipping to change at line 168
if app == None: if app == None:
# Initialise. # Initialise.
app = wx.App(redirect=False) app = wx.App(redirect=False)
# Build the GUI. # Build the GUI.
app.gui = relax_gui.Main(parent=None, id=-1, title="") app.gui = relax_gui.Main(parent=None, id=-1, title="")
# Execute the GUI tests. # Execute the GUI tests.
gui_runner = GUI_test_runner() gui_runner = GUI_test_runner()
self.runner.category = 'gui' self.runner.category = 'gui'
self.gui_result = gui_runner.run(self.tests, runner=self.runner) self.gui_result = gui_runner.run(self.tests, runner=self.runner, list_tests=self.list_tests)
# Clean up for the GUI, if not in GUI mode. # Clean up for the GUI, if not in GUI mode.
if status.test_mode: if status.test_mode:
# Terminate the interpreter thread to allow the tests to cle anly exit. # Terminate the interpreter thread to allow the tests to cle anly exit.
interpreter_thread = interpreter.Interpreter() interpreter_thread = interpreter.Interpreter()
interpreter_thread.exit() interpreter_thread.exit()
# Stop the GUI main loop. # Stop the GUI main loop.
app.ExitMainLoop() app.ExitMainLoop()
# No wx module installed. # No wx module installed.
else: else:
print("All GUI tests skipped due to the missing/broken wx module .\n") print("All GUI tests skipped due to the missing/broken wx module .\n")
self.gui_result = 'skip' self.gui_result = 'skip'
# Print out a summary of the test suite. # Print out a summary of the test suite.
if summary: if summary and not self.list_tests:
self.summary() self.summary()
# Catch the keyboard interrupt. # Catch the keyboard interrupt.
except KeyboardInterrupt: except KeyboardInterrupt:
print("\nKeyboardInterrupt: Terminating all tests.\n") print("\nKeyboardInterrupt: Terminating all tests.\n")
sys.exit(1) sys.exit(1)
# Catch GUI app set up errors. # Catch GUI app set up errors.
except: except:
print("Failure in setting up the GUI tests.\n") print("Failure in setting up the GUI tests.\n")
print_exc() print_exc()
if summary: if summary and not self.list_tests:
self.summary() self.summary()
self.gui_result = 'skip' self.gui_result = 'skip'
return False return False
# All tests were run successfully. # All tests were run successfully.
return self.gui_result return self.gui_result
def run_system_tests(self, summary=True, reset=True): def run_system_tests(self, summary=True, reset=True):
"""Execute the system/functional tests. """Execute the system/functional tests.
skipping to change at line 222 skipping to change at line 228
status.skipped_tests = [] status.skipped_tests = []
# Run the tests, catching the keyboard interrupt. # Run the tests, catching the keyboard interrupt.
try: try:
# Print a header. # Print a header.
title(file=sys.stdout, text='System / functional tests') title(file=sys.stdout, text='System / functional tests')
# Run the tests. # Run the tests.
system_runner = System_test_runner() system_runner = System_test_runner()
self.runner.category = 'system' self.runner.category = 'system'
self.system_result = system_runner.run(self.tests, runner=self.runne r) self.system_result = system_runner.run(self.tests, runner=self.runne r, list_tests=self.list_tests)
# Print out a summary of the test suite. # Print out a summary of the test suite.
if summary: if summary and not self.list_tests:
self.summary() self.summary()
# Catch the keyboard interrupt. # Catch the keyboard interrupt.
except KeyboardInterrupt: except KeyboardInterrupt:
print("\nKeyboardInterrupt: Terminating all tests.\n") print("\nKeyboardInterrupt: Terminating all tests.\n")
sys.exit(1) sys.exit(1)
# All tests were run successfully. # All tests were run successfully.
return self.system_result return self.system_result
skipping to change at line 259 skipping to change at line 265
status.skipped_tests = [] status.skipped_tests = []
# Run the tests, catching the keyboard interrupt. # Run the tests, catching the keyboard interrupt.
try: try:
# Print a header. # Print a header.
title(file=sys.stdout, text='Unit tests') title(file=sys.stdout, text='Unit tests')
# Run the tests. # Run the tests.
unit_runner = Unit_test_runner(root_path=status.install_path+os.sep+ 'test_suite'+os.sep+'unit_tests') unit_runner = Unit_test_runner(root_path=status.install_path+os.sep+ 'test_suite'+os.sep+'unit_tests')
self.runner.category = 'unit' self.runner.category = 'unit'
self.unit_result = unit_runner.run(self.tests, runner=self.runner) self.unit_result = unit_runner.run(self.tests, runner=self.runner, l ist_tests=self.list_tests)
# Print out a summary of the test suite. # Print out a summary of the test suite.
if summary: if summary and not self.list_tests:
self.summary() self.summary()
# Catch the keyboard interrupt. # Catch the keyboard interrupt.
except KeyboardInterrupt: except KeyboardInterrupt:
print("\nKeyboardInterrupt: Terminating all tests.\n") print("\nKeyboardInterrupt: Terminating all tests.\n")
sys.exit(1) sys.exit(1)
# All tests were run successfully. # All tests were run successfully.
return self.unit_result return self.unit_result
skipping to change at line 294 skipping to change at line 300
status.skipped_tests = [] status.skipped_tests = []
# Run the tests, catching the keyboard interrupt. # Run the tests, catching the keyboard interrupt.
try: try:
# Print a header. # Print a header.
title(file=sys.stdout, text='Software verification tests') title(file=sys.stdout, text='Software verification tests')
# Run the tests. # Run the tests.
verification_runner = Verification_test_runner() verification_runner = Verification_test_runner()
self.runner.category = 'verification' self.runner.category = 'verification'
self.verification_result = verification_runner.run(self.tests, runne r=self.runner) self.verification_result = verification_runner.run(self.tests, runne r=self.runner, list_tests=self.list_tests)
# Print out a summary of the test suite. # Print out a summary of the test suite.
if summary: if summary and not self.list_tests:
self.summary() self.summary()
# Catch the keyboard interrupt. # Catch the keyboard interrupt.
except KeyboardInterrupt: except KeyboardInterrupt:
print("\nKeyboardInterrupt: Terminating all tests.\n") print("\nKeyboardInterrupt: Terminating all tests.\n")
sys.exit(1) sys.exit(1)
# All tests were run successfully. # All tests were run successfully.
return self.verification_result return self.verification_result
skipping to change at line 323 skipping to change at line 329
# The skipped tests. # The skipped tests.
if status.skip_blacklisted_tests: if status.skip_blacklisted_tests:
self.summary_skipped() self.summary_skipped()
# Subtitle. # Subtitle.
section(file=sys.stdout, text="Synopsis") section(file=sys.stdout, text="Synopsis")
# System/functional test summary. # System/functional test summary.
if hasattr(self, 'system_result'): if hasattr(self, 'system_result'):
summary_line("System/functional tests", self.system_result) summary_line("System/functional tests", self.system_result, width=st atus.text_width)
# Unit test summary. # Unit test summary.
if hasattr(self, 'unit_result'): if hasattr(self, 'unit_result'):
summary_line("Unit tests", self.unit_result) summary_line("Unit tests", self.unit_result, width=status.text_width )
# GUI test summary. # GUI test summary.
if hasattr(self, 'gui_result'): if hasattr(self, 'gui_result'):
summary_line("GUI tests", self.gui_result) summary_line("GUI tests", self.gui_result, width=status.text_width)
# Verification test summary. # Verification test summary.
if hasattr(self, 'verification_result'): if hasattr(self, 'verification_result'):
summary_line("Software verification tests", self.verification_result ) summary_line("Software verification tests", self.verification_result , width=status.text_width)
# Synopsis. # Synopsis.
if hasattr(self, 'system_result') and hasattr(self, 'unit_result') and h asattr(self, 'gui_result') and hasattr(self, 'verification_result'): if hasattr(self, 'system_result') and hasattr(self, 'unit_result') and h asattr(self, 'gui_result') and hasattr(self, 'verification_result'):
if self.gui_result == "skip": if self.gui_result == "skip":
test_status = self.system_result and self.unit_result and self.v erification_result test_status = self.system_result and self.unit_result and self.v erification_result
else: else:
test_status = self.system_result and self.unit_result and self.g ui_result and self.verification_result test_status = self.system_result and self.unit_result and self.g ui_result and self.verification_result
summary_line("Synopsis", test_status) summary_line("Synopsis", test_status, width=status.text_width)
# End. # End.
print('\n\n') print('\n\n')
def summary_skipped(self): def summary_skipped(self):
"""Print out information about skipped tests.""" """Print out information about skipped tests."""
# Counts. # Counts.
system_count = {} system_count = {}
unit_count = {} unit_count = {}
 End of changes. 20 change blocks. 
18 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)