"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test_suite/unit_tests/unit_test_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.

unit_test_runner.py  (relax-4.1.3.src.tar.bz2):unit_test_runner.py  (relax-5.0.0.src.tar.bz2)
#!/usr/bin/env python #!/usr/bin/env python
################################################################################ ################################################################################
# # # #
# Copyright (C) 2006-2007 Gary S Thompson # # Copyright (C) 2006-2007 Gary S Thompson #
# Copyright (C) 2007-2008,2010-2014 Edward d'Auvergne # # Copyright (C) 2007-2008,2010-2014,2019 Edward d'Auvergne #
# # # #
# # # #
# This file is part of the program relax. # # This file is part of the program relax. #
# # # #
# This program is free software: you can redistribute it and/or modify # # This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by # # it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or # # the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. # # (at your option) any later version. #
# # # #
# This program is distributed in the hope that it will be useful, # # This program is distributed in the hope that it will be useful, #
skipping to change at line 58 skipping to change at line 58
version of relax that is dependant on python 2.5. version of relax that is dependant on python 2.5.
TODO: Split out runner part from search part. TODO: Split out runner part from search part.
""" """
from copy import copy from copy import copy
import os, re, sys, unittest, traceback import os, re, sys, unittest, traceback
from optparse import OptionParser from optparse import OptionParser
from textwrap import dedent from textwrap import dedent
# relax module imports. # relax module imports.
from test_suite.formatting import format_test_name
try: try:
from test_suite.relax_test_loader import RelaxTestLoader as TestLoader from test_suite.relax_test_loader import RelaxTestLoader as TestLoader
except ImportError: except ImportError:
from unittest import TestLoader from unittest import TestLoader
# constants # constants
########### ###########
PY_FILE_EXTENSION='.py' PY_FILE_EXTENSION='.py'
skipping to change at line 552 skipping to change at line 553
if elems_ok: if elems_ok:
result.append(tuple(module_norm_path)) result.append(tuple(module_norm_path))
mpath = copy(module_norm_path) mpath = copy(module_norm_path)
mpath.append(module_norm_path[-1].capitalize()) mpath.append(module_norm_path[-1].capitalize())
result.append(tuple(mpath)) result.append(tuple(mpath))
return result return result
def run(self, tests=None, runner=None): def run(self, tests=None, runner=None, list_tests=False):
"""Run a unit test or set of unit tests. """Run a unit test or set of unit tests.
@keyword tests: The list of system tests to perform. @keyword tests: The list of system tests to perform.
@type tests: list of str @type tests: list of str
@keyword runner: A unit test runner such as TextTestRunner. None ind @keyword runner: A unit test runner such as TextTestRunner. None
icates use of the default unit test runner. For an example of how to write a te indicates use of the default unit test runner. For an example of how to write
st runner see the python documentation for TextTestRunner in the python source. a test runner see the python documentation for TextTestRunner in the python sour
@type runner: Unit test runner instance (TextTestRunner, BaseGUITe ce.
stRunner subclass, etc.) @type runner: Unit test runner instance (TextTestRunner, BaseG
@return: A string indicating success or failure of the unit t UITestRunner subclass, etc.)
ests run. @keyword list_tests: A flag which if True will cause the tests to be
@rtype: str listed rather than executed.
@type list_tests: bool
@return: A string indicating success or failure of the un
it tests run.
@rtype: str
""" """
msg = "Either set self.%s to a %s directory or set search_for_%s_path in self.__init__ to True" msg = "Either set self.%s to a %s directory or set search_for_%s_path in self.__init__ to True"
if self.unit_test_directory == None: if self.unit_test_directory == None:
raise Exception(msg % ('unit_test_directory', 'unit test', 'unit_tes t')) raise Exception(msg % ('unit_test_directory', 'unit test', 'unit_tes t'))
if self.system_directory == None: if self.system_directory == None:
raise Exception(msg % ('system_directory', 'system', 'root')) raise Exception(msg % ('system_directory', 'system', 'root'))
# Title printout. # Title printout.
if self.verbose: if self.verbose:
skipping to change at line 639 skipping to change at line 642
# The module name. # The module name.
module_name = module_tuple[-2] module_name = module_tuple[-2]
# The class name. # The class name.
class_name = module_tuple[-1] class_name = module_tuple[-1]
# Load the tests. # Load the tests.
tests = load_test_case(package_path, module_name, class_name) tests = load_test_case(package_path, module_name, class_name)
# Only list the tests.
if list_tests:
for suite in tests:
for test in suite:
print(format_test_name(test.id()))
return True
if runner == None: if runner == None:
runner = unittest.TextTestRunner() runner = unittest.TextTestRunner()
if self.verbose: if self.verbose:
print('Results') print('Results')
print('-------') print('-------')
print('') print('')
# Run the unit tests and catch the TestResult object. # Run the unit tests and catch the TestResult object.
if tests != None and tests.countTestCases() != 0: if tests != None and tests.countTestCases() != 0:
 End of changes. 5 change blocks. 
12 lines changed or deleted 24 lines changed or added

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