def run(self): try: if sys.version_info < (2, 5): print("Tests cannot be run on Python 2.4 or earlier") exit(-1) elif sys.version_info < (2, 7): from unittest2 import TextTestRunner, defaultTestLoader else: from unittest import TextTestRunner, defaultTestLoader except ImportError: print("Please install Unittest2 to run the test suite") exit(-1) from tests import test_aspell_python suite = defaultTestLoader.loadTestsFromModule(test_aspell_python) if sys.version_info < (3,): from tests import test_aspell_for_python_2 suite.addTests( defaultTestLoader.loadTestsFromModule( test_aspell_for_python_2)) else: from tests import test_aspell_for_python_3 suite.addTests( defaultTestLoader.loadTestsFromModule( test_aspell_for_python_3)) runner = TextTestRunner() result = runner.run(suite) if result.wasSuccessful() is not True: raise SystemExit(int(bool(result.errors or result.failures)))
def runTestCase(tests, verbosity=0): test_result = TextTestRunner(verbosity=verbosity).run(tests) if len(test_result.errors) or len(test_result.failures): test_result.printErrors() return False else: return True
def run(self): """@todo: Docstring for run :returns: @todo """ loader = TestLoader() t = TextTestRunner() t.run(loader.loadTestsFromModule(vimdown.tests))
def test_doc(self): suite = TestSuite() for filename in os.listdir('../'): if filename.endswith(".py"): suite.addTest(doctest.DocFileSuite('../' + filename)) runner = TextTestRunner(verbosity=2) runner.run(suite)
def main(): loader = unittest2.TestLoader() suite = unittest2.TestSuite(( loader.loadTestsFromTestCase(TestAdaProp), loader.loadTestsFromTestCase(TestAdaLog), loader.loadTestsFromTestCase(TestAdaSched), loader.loadTestsFromTestCase(TestAdaClient), loader.loadTestsFromTestCase(TestAdaOta), )) runner = TextTestRunner(verbosity=2) runner.run(suite)
def main(): # flake8 flake8 = get_style_guide(exclude=['.tox', 'build']) report = flake8.check_files([BASE_DIR]) exit_code = print_report(report, flake8) if exit_code > 0: return exit_code # unit tests suite = TestLoader().discover(CODE_DIR, top_level_dir=BASE_DIR) result = TextTestRunner().run(suite) if result.wasSuccessful(): return 0 else: return 1
def run(self): if sys.version_info[0:2] <= (2, 6): from unittest2 import TextTestRunner, TestLoader else: from unittest import TextTestRunner, TestLoader try: import shapely.tests except ImportError: self.run_command('build_ext') import shapely.tests tests = TestLoader().loadTestsFromName('test_suite', shapely.tests) runner = TextTestRunner(verbosity=2) result = runner.run(tests) if result.wasSuccessful(): sys.exit(0) else: sys.exit(1)
def run(self): # Force an in-place build for testing speedups cmd = self.reinitialize_command('build_ext') setattr(cmd, 'inplace', 1) self.run_command('build_ext') if sys.version_info[0:2] <= (2, 6): try: from unittest2 import TextTestRunner, TestLoader except ImportError: raise ImportError( "unittest2 is required to run tests with python-%d.%d" % sys.version_info[0:2]) else: from unittest import TextTestRunner, TestLoader import shapely.tests tests = TestLoader().loadTestsFromName('test_suite', shapely.tests) runner = TextTestRunner(verbosity=2) result = runner.run(tests) if not result.wasSuccessful(): sys.exit(1)
def run(self): # Force an in-place build for testing speedups cmd = self.reinitialize_command('build_ext') setattr(cmd, 'inplace', 1) self.run_command('build_ext') if sys.version_info[0:2] <= (2, 6): try: from unittest2 import TextTestRunner, TestLoader except ImportError: raise ImportError( "unittest2 is required to run tests with python-%d.%d" % sys.version_info[0:2]) else: from unittest import TextTestRunner, TestLoader # Handle if --speedups={true|false} specified on command line if self.speedups is not None: import shapely.speedups if self.speedups == 'true': if not shapely.speedups.available: print("speedups are forced but unavailable") sys.exit(1) shapely.speedups.enable() elif self.speedups == 'false': shapely.speedups.available = False shapely.speedups.disable() else: print("Unrecognized speedups value: {}".format(self.speedups)) sys.exit(1) import shapely.tests tests = TestLoader().loadTestsFromName('test_suite', shapely.tests) runner = TextTestRunner(verbosity=2) result = runner.run(tests) if not result.wasSuccessful(): sys.exit(1)
def runTestCase(tests): test_result = TextTestRunner(verbosity=0).run(tests) if test_result.errors or test_result.failures: for (test, trace_back) in test_result.errors: sys.stderr.write("=================================================================\n") sys.stderr.write("Test:%s error \n" % test.id()) sys.stderr.write("%s\n" % trace_back) for (test, trace_back) in test_result.failures: sys.stderr.write("=================================================================\n") sys.stderr.write("Test:%s failure \n" % test.id()) sys.stderr.write("%s\n" % trace_back) return False else: return True
def __runner_run(self, item): # 开始run test test_suites = suite.TestSuite(item) runner = TextTestRunner(verbosity=1) result = runner.run(test_suites) self.all_result.append(result)
def runtests(test_names, test_dir='.', count_only=False, report_format='console', browser_type='Firefox', javascript_disabled=False, browsermob_enabled=False, shared_directory=None, screenshots_on=False, failfast=False, debug=False, webdriver_remote_url=None, browser_version='', browser_platform='ANY', session_name=None, extended=False): if allscrewedup : print "ENTERING runtests" if test_dir == 'selftests': # XXXX horrible hardcoding # selftests should be a command instead package_dir = os.path.dirname(__file__) test_dir = os.path.join(package_dir, 'selftests') test_dir = _get_full_path(test_dir) if not os.path.isdir(test_dir): msg = 'Specified directory %r does not exist' % test_dir print msg sys.exit(1) shared_directory = find_shared_directory(test_dir, shared_directory) config.shared_directory = shared_directory sys.path.append(shared_directory) # config.results_directory = _get_full_path('results') #config.browsermob_enabled = browsermob_enabled test_names = set(test_names) suites = get_suites(test_names, test_dir, shared_directory, count_only, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast, debug, extended=extended, ) alltests = TestSuite(suites) print alltests.__iter__ print '' print ' %s test cases loaded\n' % alltests.countTestCases() print '--------------------------------------------------------------' if not alltests.countTestCases(): print 'Error: Did not find any tests' sys.exit(1) if count_only: print 'Count-Only Enabled, Not Running Tests' sys.exit(0) print "Report Format: ", report_format if report_format == 'xml': print "Create Results Dir if does not exist" _make_results_dir() fp = None print "config.config.xml_results_file:", config.xml_results_file if config.xml_results_file is None: fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb') else: fp = file(config.xml_results_file, 'wb') # XXX failfast not supported in XMLTestRunner runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2) elif report_format == 'html': _make_results_dir() fp = file(os.path.join(config.results_directory, 'results.html'), 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=fp, title='NSUI Test Report', description='Report for this test run, please expand the \ pass/fail for detailed results', dirTestScreenshots = config.results_directory ) else: runner = TextTestRunner(verbosity=2, failfast=failfast) try: runner.run(alltests) #return runner._makeResult() except KeyboardInterrupt: print >> sys.stderr, 'Test run interrupted' finally: # XXX should warn on cases that were specified but not found pass
def runTestsInClass(classpath, test_verbosity=3): klass = ErtTestRunner.importClass(classpath) loader = TestLoader() tests = loader.loadTestsFromTestCase(klass) testRunner = TextTestRunner(verbosity=test_verbosity) testRunner.run(tests)
try: import mock except ImportError: raise ImportError("The BatchApps Python Client test suite requires " "the mock package to run on Python 3.2 and below.\n" "Please install this package to continue.") try: from teamcity import is_running_under_teamcity from teamcity.unittestpy import TeamcityTestRunner TC_BUILD = is_running_under_teamcity() except ImportError: TC_BUILD = False if __name__ == '__main__': if TC_BUILD: runner = TeamcityTestRunner() else: runner = TextTestRunner(verbosity=2) test_dir = os.path.dirname(__file__) top_dir = os.path.dirname(os.path.dirname(test_dir)) test_loader = TestLoader() suite = test_loader.discover(test_dir, pattern="unittest_*.py", top_level_dir=top_dir) runner.run(suite)
def runtests(test_names, test_dir='.', collect_only=False, report_format='console', browser_type='Firefox', javascript_disabled=False, shared_directory=None, screenshots_on=False, failfast=False, debug=False, webdriver_remote_url=None, device='', version='', browser_platform='ANY', session_name=None, browserstack_enabled=False, vagrant_enabled=False, saucelabs_enabled=False, custom_options=None, extended=False, skip_tracking=False): if test_dir == 'selftests': # XXXX horrible hardcoding # selftests should be a command instead package_dir = os.path.dirname(__file__) test_dir = os.path.join(package_dir, 'selftests') test_dir = _get_full_path(test_dir) if not os.path.isdir(test_dir): msg = 'Specified directory %r does not exist' % test_dir print msg sys.exit(1) shared_directory = find_shared_directory(test_dir, shared_directory) config.shared_directory = shared_directory sys.path.append(shared_directory) config.results_directory = _get_full_path('results') config.saucelabs_enabled = saucelabs_enabled config.browserstack_enabled = browserstack_enabled config.vagrant_enabled = vagrant_enabled test_names = set(test_names) suites = get_suites(test_names, test_dir, shared_directory, collect_only, browser_type, device, version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast, debug, saucelabs_enabled=saucelabs_enabled, browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled, skip_tracking=skip_tracking, custom_options=custom_options, extended=extended ) alltests = TestSuite(suites) if not alltests.countTestCases(): print 'Error: Did not find any tests' sys.exit(1) if collect_only: print 'Collect-Only Enabled, Not Running Tests...\n' print 'Tests Collected:' print '-' * 16 for t in sorted(testtools.testsuite.iterate_tests(alltests)): print t.id() sys.exit(0) if report_format == 'xml': _make_results_dir() fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb') # XXX failfast not supported in XMLTestRunner runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2) elif report_format == 'html': _make_results_dir() fp = file(os.path.join(config.results_directory, 'results.html'), 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=fp, title='SST Test Report', verbosity=2, failfast=failfast ) else: if config.email_notification_enabled: stream = cStringIO.StringIO() else: stream = sys.stderr runner = TextTestRunner(verbosity=2, failfast=failfast, stream=stream, resultclass=SSTTextTestResult) try: return runner.run(alltests) except KeyboardInterrupt: print >> sys.stderr, 'Test run interrupted' finally: # XXX should warn on cases that were specified but not found pass
def runTestSuite(tests, test_verbosity=3): test_runner = TextTestRunner(verbosity=test_verbosity) result = test_runner.run(tests) return result.wasSuccessful()
except ImportError: raise ImportError("The ADAL test suite requires the unittest2 " "package to run on Python 2.6 and below.\n" "Please install this package to continue.") else: from unittest import TestLoader, TextTestRunner if sys.version_info[:2] >= (3, 3, ): from unittest import mock else: try: import mock except ImportError: raise ImportError("The ADAL test suite requires the mock " "package to run on Python 3.2 and below.\n" "Please install this package to continue.") if __name__ == '__main__': runner = TextTestRunner(verbosity=2) test_dir = os.path.dirname(__file__) top_dir = os.path.dirname(os.path.dirname(test_dir)) test_loader = TestLoader() suite = test_loader.discover(test_dir, pattern="test_*.py", top_level_dir=top_dir) runner.run(suite)
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys if sys.version_info[:2] <= (2,6): from unittest2 import TestLoader, TextTestRunner else: from unittest import TestLoader, TextTestRunner testdir = os.path.split(os.path.abspath(__file__))[0] topdir = os.path.split(testdir)[0] libdir = os.path.join(topdir, 'lib') os.chdir(testdir) sys.path.insert(0, libdir) loader = TestLoader() tests = loader.discover('.', 'flow_*.py') runner = TextTestRunner(verbosity=2, buffer=True) runner.run(tests)
"package to run on Python 2.6 and below.\n" "Please install this package to continue.") else: from unittest import TestLoader, TextTestRunner if sys.version_info[:2] >= ( 3, 3, ): from unittest import mock else: try: import mock except ImportError: raise ImportError("The ADAL test suite requires the mock " "package to run on Python 3.2 and below.\n" "Please install this package to continue.") if __name__ == '__main__': runner = TextTestRunner(verbosity=2) test_dir = os.path.dirname(__file__) top_dir = os.path.dirname(os.path.dirname(test_dir)) test_loader = TestLoader() suite = test_loader.discover(test_dir, pattern="test_*.py", top_level_dir=top_dir) runner.run(suite)
def runtests(test_names, test_dir='.', file_match='*.py', report_format='console', browser_type='Firefox', javascript_disabled=False, browsermob_enabled=False, shared_directory=None, screenshots_on=False, failfast=False, debug=False, webdriver_remote_url=None, browser_version='', browser_platform='ANY', session_name=None, extended=False): if test_dir == 'selftests': # XXXX horrible hardcoding # selftests should be a command instead package_dir = os.path.dirname(__file__) test_dir = os.path.join(package_dir, 'selftests') test_dir = _get_full_path(test_dir) if not os.path.isdir(test_dir): msg = 'Specified directory %r does not exist' % test_dir print msg sys.exit(1) shared_directory = find_shared_directory(test_dir, shared_directory) config.shared_directory = shared_directory sys.path.append(shared_directory) config.results_directory = _get_full_path('results') config.browsermob_enabled = browsermob_enabled found_tests = set() test_names = set(test_names) suites = ( get_suite( test_names, root, file_match, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, found_tests, failfast, debug, extended=extended, ) for root, _, _ in os.walk(test_dir, followlinks=True) if os.path.abspath(root) != shared_directory and not os.path.abspath(root).startswith(shared_directory + os.path.sep) and not os.path.split(root)[1].startswith('_') ) alltests = TestSuite(suites) print '' print ' %s test cases loaded\n' % alltests.countTestCases() print '--------------------------------------------------------------' if not alltests.countTestCases(): print 'Error: Did not find any tests' sys.exit(1) if report_format == 'xml': _make_results_dir() fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb') # XXX failfast not supported in XMLTestRunner runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2) elif report_format == 'html': _make_results_dir() fp = file(os.path.join(config.results_directory, 'results.html'), 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=fp, title='SST Test Report', verbosity=2, failfast=failfast ) else: runner = TextTestRunner(verbosity=2, failfast=failfast) try: runner.run(alltests) except KeyboardInterrupt: print >> sys.stderr, 'Test run interrupted' finally: missing = test_names - found_tests for name in missing: msg = 'Warning: test %r not found' % name print >> sys.stderr, msg
def runTestsInDirectory(path="."): loader = TestLoader() tests = loader.discover(path) testRunner = TextTestRunner() testRunner.run(tests)
def runTestsInClass(classpath): klass = importClass(classpath) loader = TestLoader() tests = loader.loadTestsFromTestCase(klass) testRunner = TextTestRunner() testRunner.run(tests)
#!/usr/bin/env python import os import sys from unittest2 import TestLoader, TextTestRunner if __name__ == '__main__': tests_dir = os.path.dirname(os.path.abspath(__file__)) authorize_dir = os.path.join(tests_dir, os.path.pardir) sys.path.append(authorize_dir) suite = TestLoader().discover(tests_dir) runner = TextTestRunner(verbosity=1) result = runner.run(suite) sys.exit(not result.wasSuccessful())
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys if sys.version_info[:2] <= (2, 6): from unittest2 import TestLoader, TextTestRunner else: from unittest import TestLoader, TextTestRunner testdir = os.path.split(os.path.abspath(__file__))[0] topdir = os.path.split(testdir)[0] libdir = os.path.join(topdir, 'lib') os.chdir(testdir) sys.path.insert(0, libdir) loader = TestLoader() tests = loader.discover('.', 'flow_*.py') runner = TextTestRunner(verbosity=2, buffer=True) runner.run(tests)