class TestHTMLTestRunner(TestCase): def setUp(self): self.suite = TestSuite() self.loader = TestLoader() self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestPass)) self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestFail)) self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestBasic)) self.results_output_buffer = StringIO() HTMLTestRunner(stream=self.results_output_buffer).run(self.suite) self.byte_output = self.results_output_buffer.getvalue() def test_SampleTestPass(self): output1="".join(self.byte_output.split()) output2="".join(SampleTestPass.EXPECTED_RESULT.split()) self.assertGreater(output1.find(output2),0) @skip("Test Skipping") def test_SampleTestSkip(self): self.fail("This error should never be displayed") def test_SampleTestFail(self): output1="".join(self.byte_output.split()) output2="".join(SampleTestFail.EXPECTED_RESULT.split()) self.assertGreater(output1.find(output2),0) def test_SampleTestBasic(self): output1="".join(self.byte_output.split()) output2="".join(SampleTestBasic.EXPECTED_RESULT.split()) self.assertGreater(output1.find(output2),0)
def loadTestsFromModule(self, module): """ Return a suite of all tests cases contained in the given module """ tests = [TestLoader.loadTestsFromModule(self,module)] if hasattr(module, "additional_tests"): tests.append(module.additional_tests()) if hasattr(module, '__path__'): for dir in module.__path__: for file in os.listdir(dir): if file.endswith('.py') and file!='__init__.py': if file.lower().startswith('test'): submodule = module.__name__+'.'+file[:-3] else: continue else: subpkg = os.path.join(dir,file,'__init__.py') if os.path.exists(subpkg): submodule = module.__name__+'.'+file else: continue tests.append(self.loadTestsFromName(submodule)) if len(tests)>1: return self.suiteClass(tests) else: return tests[0] # don't create a nested suite for only one return
def all(): ''' This runs all tests and examples. It is something of a compromise - seems to be the best solution that's independent of other libraries, doesn't use the file system (since code may be in a zip file), and keeps the number of required imports to a minimum. ''' basicConfig(level=ERROR) log = getLogger('lepl._test.all.all') suite = TestSuite() loader = TestLoader() runner = TextTestRunner(verbosity=4) for module in ls_modules(lepl, MODULES): log.debug(module.__name__) suite.addTest(loader.loadTestsFromModule(module)) result = runner.run(suite) print('\n\n\n----------------------------------------------------------' '------------\n') if version[0] == '2': print('Expect 2-5 failures + 2 errors in Python 2: {0:d}, {1:d} ' .format(len(result.failures), len(result.errors))) assert 2 <= len(result.failures) <= 5, len(result.failures) assert 1 <= len(result.errors) <= 2, len(result.errors) target = TOTAL - NOT_DISTRIBUTED - NOT_3 else: print('Expect at most 1 failure + 0 errors in Python 3: {0:d}, {1:d} ' .format(len(result.failures), len(result.errors))) assert 0 <= len(result.failures) <= 1, len(result.failures) assert 0 <= len(result.errors) <= 0, len(result.errors) target = TOTAL - NOT_DISTRIBUTED print('Expect {0:d} tests total: {1:d}'.format(target, result.testsRun)) assert result.testsRun == target, result.testsRun print('\nLooks OK to me!\n\n')
def loadTestsFromModule(self, module): """Load unit test (skip 'interop' package). Hacked from the version in 'setuptools.command.test.ScanningLoader'. """ tests = [] tests.append(TestLoader.loadTestsFromModule(self,module)) if hasattr(module, '__path__'): for file in resource_listdir(module.__name__, ''): if file == 'interop': # These tests require installing a bunch of extra # code: see 'src/soaplib/test/README'. continue if file.endswith('.py') and file != '__init__.py': submodule = module.__name__ + '.' + file[:-3] else: if resource_exists( module.__name__, file + '/__init__.py' ): submodule = module.__name__ + '.' + file else: continue tests.append(self.loadTestsFromName(submodule)) return self.suiteClass(tests)
def loadTestsFromModule(self, module): """Return a suite of all tests cases contained in the given module If the module is a package, load tests from all the modules in it. If the module has an ``additional_tests`` function, call it and add the return value to the tests. """ tests = [] if module.__name__ != 'setuptools.tests.doctest': # ugh tests.append(TestLoader.loadTestsFromModule(self, module)) if hasattr(module, "additional_tests"): tests.append(module.additional_tests()) if hasattr(module, '__path__'): for file in resource_listdir(module.__name__, ''): if file.endswith('.py') and file != '__init__.py': submodule = module.__name__ + '.' + file[:-3] else: if resource_exists(module.__name__, file + '/__init__.py'): submodule = module.__name__+'.'+file else: continue tests.append(self.loadTestsFromName(submodule)) if len(tests) != 1: return self.suiteClass(tests) else: return tests[0] # don't create a nested suite for only one return
def search(path, prefix=''): loader = TestLoader() for _, name, is_pkg in iter_modules(path): full_name = '{}.{}'.format(prefix, name) module_path = os.path.join(path[0], name) if is_pkg: search([module_path], full_name) if not is_pkg and name.startswith('test'): test_module = import_module(full_name) for suite in loader.loadTestsFromModule(test_module): for test in suite._tests: path = '{}.{}.{}'.format(full_name, test.__class__.__name__, test._testMethodName) rec = { 'ver': '1.0', 'execution': { 'command': 'python -m unittest {}'.format(path), 'recording': find_recording_file(path) }, 'classifier': { 'identifier': path, 'type': get_test_type(test), } } RECORDS.append(rec)
def run_daemon(testpath, testname, amqp): module = load_source(testname, testpath) loader = TestLoader() suite = loader.loadTestsFromModule(module) result = CanopsisTestResult(module.__name__, amqp) suite.run(result) result.report()
def run_suite(verbose=False): loader = TestLoader() runner = TextTestRunner(verbosity=2 if verbose else 1) suite = TestSuite() for mod in get_modules(): suite.addTest(loader.loadTestsFromModule(mod)) runner.run(suite) return 0
def create_test_suite(): """create a unittest.TestSuite with available tests""" from unittest import TestLoader, TestSuite loader = TestLoader() suite = TestSuite() for test_name in available_tests: exec("from . import " + test_name) suite.addTests(loader.loadTestsFromModule(eval(test_name))) return suite
def run(self): address = self.address or 'localhost:10190' os.environ.setdefault('URLFETCH_ADDR', address) import pyurlfetch.tests loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(pyurlfetch.tests))
def loadTestsFromModule(self, module): """Load unit test for tests directory """ tests = list() tests.append(TestLoader.loadTestsFromModule(self, module)) if hasattr(module, '__path__'): for file in resource_listdir(module.__name__, ''): if file.endswith('.py') and file != '__init__.py': submodule = module.__name__ + '.' + file[:-3] else: if resource_exists(module.__name__, file + '/__init__.py'): submodule = module.__name__ + '.' + file else: continue tests.append(self.loadTestsFromName(submodule)) return self.suiteClass(tests)
def collect_tests(path, return_collection, prefix=''): from unittest import TestLoader from importlib import import_module from pkgutil import iter_modules loader = TestLoader() for _, name, is_pkg in iter_modules(path): full_name = '{}.{}'.format(prefix, name) module_path = os.path.join(path[0], name) if is_pkg: collect_tests([module_path], return_collection, full_name) if not is_pkg and name.startswith('test'): test_module = import_module(full_name) for suite in loader.loadTestsFromModule(test_module): for test in suite._tests: # pylint: disable=protected-access return_collection.append( '{}.{}.{}'.format(full_name, test.__class__.__name__, test._testMethodName)) # pylint: disable=protected-access
def run(self): appengine_path = self.appengine_path or '/' extra_paths = [ appengine_path, os.path.join(appengine_path, 'lib', 'antlr3'), os.path.join(appengine_path, 'lib', 'django_0_96'), os.path.join(appengine_path, 'lib', 'fancy_urllib'), os.path.join(appengine_path, 'lib', 'ipaddr'), os.path.join(appengine_path, 'lib', 'webob'), os.path.join(appengine_path, 'lib', 'yaml', 'lib'), os.path.join(appengine_path, 'lib', 'lib', 'simplejson'), os.path.join(appengine_path, 'lib', 'lib', 'graphy'), ] sys.path.extend(extra_paths) import apptrace.tests loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(apptrace.tests))
def run(self): gae_sdk = self.gae_sdk or '/' extra_paths = [ gae_sdk, os.path.join(gae_sdk, 'lib', 'antlr3'), os.path.join(gae_sdk, 'lib', 'django'), os.path.join(gae_sdk, 'lib', 'fancy_urllib'), os.path.join(gae_sdk, 'lib', 'ipaddr'), os.path.join(gae_sdk, 'lib', 'webob'), os.path.join(gae_sdk, 'lib', 'yaml', 'lib'), os.path.join(gae_sdk, 'lib', 'simplejson'), os.path.join(gae_sdk, 'lib', 'graphy'), ] sys.path.extend(extra_paths) import gaesynkit.tests loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(gaesynkit.tests))
def all(): ''' This runs all tests and examples. It is something of a compromise - seems to be the best solution that's independent of other libraries, doesn't use the file system (since code may be in a zip file), and keeps the number of required imports to a minimum. ''' #basicConfig(level=DEBUG) log = getLogger('lepl._test.all.all') suite = TestSuite() loader = TestLoader() runner = TextTestRunner(verbosity=2) for module in ls_all_tests(): log.debug(module.__name__) suite.addTest(loader.loadTestsFromModule(module)) result = runner.run(suite) print('\n\n\n----------------------------------------------------------' '------------\n') if version[0] == '2': print('Expect 4-5 failures + 1 error in Python 2.6: {0:d}, {1:d} ' '(lenient comparison, format variation from address size, ' 'unicode ranges, weird string difference)' .format(len(result.failures), len(result.errors))) assert 4 <= len(result.failures) <= 5, len(result.failures) assert 1 <= len(result.errors) <= 1, len(result.errors) target = TOTAL - 22 - 9 # no bin/cairo tests (22) else: print('Expect at most 1 failure + 0 errors in Python 3: {0:d}, {1:d} ' '(format variations from address size?)' .format(len(result.failures), len(result.errors))) assert 0 <= len(result.failures) <= 1, len(result.failures) assert 0 <= len(result.errors) <= 0, len(result.errors) target = TOTAL - 9 # no cairo tests (2), no random (1), no support[3] (6) print('Expect {0:d} tests total: {1:d}'.format(target, result.testsRun)) assert result.testsRun == target, result.testsRun print('\nLooks OK to me!\n\n')
def run(self): import tests loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(tests))
class AutomaticTestRunner: def __init__(self): self.loader = TestLoader() self.runner = TextTestRunner() def runTests(self): testCaseNames = self.findTestCaseNames() testCaseModules = self.loadTestCaseModules(testCaseNames) testSuite = self.loadTestsFromModules(testCaseModules) return self.runner.run(testSuite) def findTestCaseNames(self): rootSuite = __import__('test') rootSuitePath = rootSuite.__path__[0] return self.findTestCaseNamesFromDirectory(rootSuitePath) def loadTestCaseModules(self, testCaseNames): testCaseModules = [] for testCaseName in testCaseNames: testCaseModule = __import__(testCaseName, {}, {}, ['a']) testCaseModules.append(testCaseModule) return testCaseModules def loadTestsFromModules(self, testCaseModules): suite = TestSuite() for testCaseModule in testCaseModules: subSuite = self.loader.loadTestsFromModule(testCaseModule) suite.addTest(subSuite) return suite def findTestCaseNamesFromDirectory(self, rootPath): subFiles = os.listdir(rootPath) testModuleNames = self.findSubModuleNames(rootPath, subFiles) subSuitePaths = self.findSubSuitePaths(rootPath, subFiles) subSuiteTestModuleNames = self.findTestCaseNamesFromSubSuitePaths(subSuitePaths) testModuleNames.extend(subSuiteTestModuleNames) return testModuleNames def findSubModuleNames(self, rootPath, subFiles): testModuleNames = [] for subFile in subFiles: subFilePath = rootPath + '/' + subFile if os.path.isfile(subFilePath) and subFile.endswith('.py') and not subFile.startswith('__'): rootModuleName = os.path.relpath(rootPath).replace('/', '.') testModuleName = rootModuleName + '.' + subFile[0:-3] testModuleNames.append(testModuleName) return testModuleNames def findSubSuitePaths(self, rootPath, subFiles): subSuitePaths = [] for subFile in subFiles: subFilePath = rootPath + '/' + subFile if os.path.isdir(subFilePath) and not subFile.startswith('__'): subSuitePaths.append(subFilePath) return subSuitePaths def findTestCaseNamesFromSubSuitePaths(self, subSuitePaths): testModuleNames = [] for subSuitePath in subSuitePaths: subTestModuleNames = self.findTestCaseNamesFromDirectory(subSuitePath) testModuleNames.extend(subTestModuleNames) return testModuleNames
# 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 # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Import from the Standard Library from unittest import TestLoader, TestSuite, TextTestRunner # Import tests import test_metadata import test_server test_modules = [test_metadata, test_server] loader = TestLoader() if __name__ == '__main__': suite = TestSuite() for module in test_modules: suite.addTest(loader.loadTestsFromModule(module)) TextTestRunner(verbosity=1).run(suite)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import logging from unittest import TestLoader, TextTestRunner import tests def set_logger_level(level): from scriptgen import __name__ as module_name logging.basicConfig() logging.getLogger(module_name).setLevel(level) if __name__ == '__main__': set_logger_level(logging.INFO) loader = TestLoader() suite = loader.loadTestsFromModule(tests) test_runner = TextTestRunner() test_runner.run(suite)
def run(self): import tests.unit.test_15p loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(tests.unit.test_15p))
test_heading, test_image, test_link, test_list, test_meta, test_note, test_paragraph, test_reference, test_section, test_shapes, test_span, test_style, test_styles, test_table, test_text, test_tracked_changes, test_utils, test_variable, test_xmlpart, ] loader = TestLoader() if __name__ == "__main__": suite = TestSuite() for module in test_modules: suite.addTest(loader.loadTestsFromModule(module)) TextTestRunner(verbosity=1).run(suite)
action="store_true", ) parser.add_argument( "-r", "--remote", help="Run against which tenant in production staging environment", type=str, default=None, ) args = parser.parse_args() if args.local: pyinventory_tests.utils.TEST_MODE = TestMode.LOCAL elif args.remote is not None: pyinventory_tests.utils.TEST_MODE = TestMode.REMOTE pyinventory_tests.utils.TENANT = args.remote loader = TestLoader() loader.testNamePatterns = [args.pattern] suite = loader.loadTestsFromModule(pyinventory_tests) if args.output: runner = XMLTestRunner(output=args.output, verbosity=2) else: runner = TextTestRunner(verbosity=2) result = runner.run(suite) if len(result.errors) != 0 or len(result.failures) != 0: sys.exit(1) sys.exit(0)
for _ in range(3): print(".", end="", flush=True) time.sleep(1) print(" Done!") # Import here to only initiate RPC connection after ganache is running. from tests import * test_settings = load_test_settings() test_suite = TestSuite() loader = TestLoader() for item in test_settings: if test_settings[item]: test_suite.addTests( loader.loadTestsFromModule(getattr(tests, item))) print("Running test suite...\n") result = TextTestRunner(verbosity=2).run(test_suite) from utils.deployutils import PERFORMANCE_DATA for i in PERFORMANCE_DATA: for j in PERFORMANCE_DATA[i]: vals = PERFORMANCE_DATA[i][j] # (avg, min, max, calls) PERFORMANCE_DATA[i][j] = (vals[0] // vals[1], vals[2], vals[3], vals[1]) PERFORMANCE_DATA['CONTRACT'] = { 'METHOD': ['AVG_GAS', 'MIN_GAS', 'MAX_GAS', "CALLS"] }
from unittest import TextTestRunner, TestLoader import test_acceptance import test_merger if __name__ == '__main__': # load tests test_loader = TestLoader() suite = test_loader.loadTestsFromModule(test_acceptance) suite.addTest(test_loader.loadTestsFromModule(test_merger)) # run suite TextTestRunner().run(suite)
def run(self): loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(wpolyanna.test))
always requires a reconfiguration of OS-level virtualization features and a reboot before one or the other collection of tests can be run. Therefore if you want to run the unit-tests below, you currently have to cherry-pick the ones that can be run together on your particular host-platform environment & configuration. """ from unittest import TestLoader, TestSuite from tests.runner.test_runner import SurePhyreTestRunner import tests.test_android_docker import tests.test_alpine_linux_docker import tests.test_linux_docker import tests.test_macos_vagrant import tests.test_win32_docker import tests.test_win32_native # TODO: we could add some clever host-environment detection logic to even # automate the decision which tests can or can not be run loader = TestLoader() suite = TestSuite(( # loader.loadTestsFromModule(tests.test_android_docker), loader.loadTestsFromModule(tests.test_alpine_linux_docker), loader.loadTestsFromModule(tests.test_linux_docker), # loader.loadTestsFromModule(tests.test_macos_vagrant), # loader.loadTestsFromModule(tests.test_win32_docker), # loader.loadTestsFromModule(tests.test_win32_native), )) runner = SurePhyreTestRunner() runner.run(suite)
def test_suite(): loader = TestLoader() result = loader.loadTestsFromModule(test_chunked) result.addTest(loader.loadTestsFromModule(test_details)) result.addTest(loader.loadTestsFromModule(test_filters)) result.addTest(loader.loadTestsFromModule(test_progress_model)) result.addTest(loader.loadTestsFromModule(test_test_results)) result.addTest(loader.loadTestsFromModule(test_test_protocol)) result.addTest(loader.loadTestsFromModule(test_test_protocol2)) result.addTest(loader.loadTestsFromModule(test_tap2subunit)) result.addTest(loader.loadTestsFromModule(test_subunit_filter)) result.addTest(loader.loadTestsFromModule(test_subunit_tags)) result.addTest(loader.loadTestsFromModule(test_subunit_stats)) result.addTest(loader.loadTestsFromModule(test_run)) return result
class ModuleTest: def __init__(self, verbosity: int = 1, verbose_result: bool = False): self._tested_modules: int = 0 self._total_errors: int = 0 self._total_failures: int = 0 self._total_skipped: int = 0 self._total_tested: int = 0 self.test_loader = TestLoader() self.test_suite = None self.runner = TextTestRunner(verbosity=verbosity) self.test_result: Union[TestResult, None] = None self.verbose_result = verbose_result def _record_results(self): self._total_errors += len(self.test_result.errors) self._total_failures += len(self.test_result.failures) self._total_skipped += len(self.test_result.skipped) self._total_tested += self.test_result.testsRun def print_result(self, name: str): print(f"Tested {name} module.") print(f"Errors: {len(self.test_result.errors)}.") print(f"Failures: {len(self.test_result.failures)}.") print(f"Skipped: {len(self.test_result.skipped)}.") print(f"Tested: {self.test_result.testsRun}.", end="\n\n") def print_total_results(self): print(f"Tested {self._tested_modules} modules.") print(f"Total errors: {self._total_errors}.") print(f"Total failures: {self._total_failures}.") print(f"Total skipped: {self._total_skipped}.") print(f"Total tested: {self._total_tested}.", end="\n\n") def test_module(self, module) -> bool: self._tested_modules += 1 self.test_suite = self.test_loader.loadTestsFromModule(module) self.test_result = self.runner.run(self.test_suite) if self.verbose_result: self.print_result(module.__name__) self._record_results() if (len(self.test_result.errors) > 0 or len(self.test_result.failures) > 0): return False return True def _is_only_modules(self, module_list): is_only_modules = True for index, module in enumerate(module_list): if not isinstance(module, ModuleType): is_only_modules = False if self.verbose_result: print(f"Found not a module at {index} position.") return is_only_modules def test_chain(self, module_list): if not self._is_only_modules(module_list): print("Test aborted.") return is_no_errors = True for module in module_list: if is_no_errors: is_no_errors = self.test_module(module) if not is_no_errors: print(f"Test chain broken in {module.__name__} module.") else: print(f"Skip testing for module {module.__name__}.") if self.verbose_result: self.print_total_results() return is_no_errors
from unittest import TestLoader, TestSuite, TextTestRunner import test_demo from test_demo import MyTest loader = TestLoader() suite = TestSuite( [loader.loadTestsFromModule(test_demo), loader.loadTestsFromTestCase(MyTest)] ) runner = TextTestRunner(verbosity=2) runner.run(suite)
model1 = cobra.io.json.load_json_model(SIMPLE_2_MODEL) universe1 = cobra.io.json.load_json_model(SIMPLE_2_UNIVERSE) rxn_probs2 = probanno.ReactionProbabilities.from_json_file(SIMPLE_2_REACTION_PROBABILITIES) reactions = probanno.probabilistic_gapfill(model1, universe1, rxn_probs2) reaction_ids = [r.id for r in reactions[0]] self.assertTrue('a2e' in reaction_ids) self.assertTrue('e2f' in reaction_ids) self.assertTrue('f2d' in reaction_ids) self.assertTrue('e2b' not in reaction_ids) self.assertTrue('a2b' not in reaction_ids) self.assertTrue('c2f' not in reaction_ids) self.assertTrue('c2d' not in reaction_ids) self.assertTrue('e2c' not in reaction_ids) # make a test suite to run all of the tests loader = TestLoader() suite = loader.loadTestsFromModule(sys.modules[__name__]) def test_all(): TextTestRunner(verbosity=2).run(suite) if __name__ == "__main__": test_all()
from element_location import element_location_test from element_state import visibility_test from element_state import method_test from element_state import properties from javascript import execute_script_test from user_input import clear_test from windows import window_manipulation from windows import tabbing if __name__ == "__main__": loader = TestLoader() suite = TestSuite(( loader.loadTestsFromModule(cookie_test), loader.loadTestsFromModule(forward), loader.loadTestsFromModule(forwardToNothing), loader.loadTestsFromModule(element_location_test), loader.loadTestsFromModule(visibility_test), loader.loadTestsFromModule(execute_script_test), loader.loadTestsFromModule(clear_test), loader.loadTestsFromModule(method_test), loader.loadTestsFromModule(properties), loader.loadTestsFromModule(refresh_page), loader.loadTestsFromModule(get_from_http_test), loader.loadTestsFromModule(window_manipulation), loader.loadTestsFromModule(tabbing) )) runner = TextTestRunner(verbosity=2)
except AssertionError as e: result = '用例不通过' raise e else: result = '用例通过' finally: print(result) def test_error(self): """ 账号或者密码输入错误 """ expected = '{"code":0,"mes":"账号或者密码不正确"}' res = login_check(username='******', password='******') self.assertEqual(expected, res) try: self.assertEqual(expected, res) except AssertionError as e: result = '用例不通过' raise e else: result = '用例通过' finally: print(result) if __name__ == '__main__': suit = TestCase() loader = TestLoader() suit.addTest(loader.loadTestsFromModule(MyTestCase, TestLogin)) runner = TextTestRunner() runner.run(suit)
def HackerCodecsSuite(): loader = TestLoader() suite = loader.loadTestsFromModule(test_hackercodecs) suite.addTests(doctest.DocTestSuite(hackercodecs)) return suite
def test_suite(): loader = TestLoader() result = loader.loadTestsFromModule(test_chunked) result.addTest(loader.loadTestsFromModule(test_details)) result.addTest(loader.loadTestsFromModule(test_filters)) result.addTest(loader.loadTestsFromModule(test_progress_model)) result.addTest(loader.loadTestsFromModule(test_test_results)) result.addTest(loader.loadTestsFromModule(test_test_protocol)) result.addTest(loader.loadTestsFromModule(test_test_protocol2)) result.addTest(loader.loadTestsFromModule(test_tap2subunit)) result.addTest(loader.loadTestsFromModule(test_filter_to_disk)) result.addTest(loader.loadTestsFromModule(test_subunit_filter)) result.addTest(loader.loadTestsFromModule(test_subunit_tags)) result.addTest(loader.loadTestsFromModule(test_subunit_stats)) result.addTest(loader.loadTestsFromModule(test_run)) result.addTests( generate_scenarios(loader.loadTestsFromModule(test_output_filter)) ) return result
'3UMPtex': {'minimum': 0.0, 'maximum': 0.0}, '4HOXPACDtex': {'minimum': 0.0, 'maximum': 0.0}, 'ACACtex': {'minimum': 0.0, 'maximum': 0.0}, '4PCP': {'minimum': 0.0, 'maximum': 0.0}, '4PCPpp': {'minimum': 0.0, 'maximum': 0.0}, 'AAMYLpp': {'minimum': 0.0, 'maximum': 0.0}, '4PEPTabcpp': {'minimum': 0.0, 'maximum': 0.0}, '4PEPTtex': {'minimum': 0.0, 'maximum': 0.0}, '5DGLCNR': {'minimum': 0.0, 'maximum': 0.0}, '5DGLCNt2rpp': {'minimum': 0.0, 'maximum': 0.0}, 'ACALD': {'minimum': 3.35702, 'maximum': 7.49572}} for solver in solver_dict: cobra_model = create_test_model() initialize_growth_medium(cobra_model, 'LB') fva_out = flux_variability_analysis(cobra_model, solver=solver, reaction_list=cobra_model.reactions[100:140]) for the_reaction, the_range in iteritems(fva_out): for k, v in iteritems(the_range): self.assertAlmostEqual(fva_results[the_reaction][k], v, places=5) # make a test suite to run all of the tests loader = TestLoader() suite = loader.loadTestsFromModule(sys.modules[__name__]) def test_all(): TextTestRunner(verbosity=2).run(suite) if __name__ == "__main__": test_all()
from pkgutil import extend_path __path__ = extend_path(__path__, __name__) from unittest import TestLoader, TestSuite from . import commands loader = TestLoader() suite = TestSuite() suite.addTests(loader.loadTestsFromModule(commands))