def load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(ModelTestCase)) suite.addTest(loader.loadTestsFromTestCase(FunctionAPITestCase)) suite.addTest(loader.loadTestsFromTestCase(FunctionEvaluationTest)) suite.addTest(loader.loadTestsFromTestCase(APITestCase)) return suite
def suite(): """Returns the test suite for this module.""" result = TestSuite() loader = defaultTestLoader result.addTest(loader.loadTestsFromModule(test_manager)) result.addTest(loader.loadTestsFromModule(test_search)) result.addTest(loader.loadTestsFromModule(test_validation)) result.addTest(loader.loadTestsFromModule(test_views)) return result
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 suite(): """Returns the test suite for this module.""" result = TestSuite() loader = defaultTestLoader result.addTest(loader.loadTestsFromModule(test_api)) return result
def test_given(tests): module = sys.modules[__name__] if tests == None: defaultTest = None else: loader = TestLoader() defaultTest = TestSuite() tests = loader.loadTestsFromNames(tests, module) defaultTest.addTests(tests) main(defaultTest=defaultTest)
def test_suite(): suite = TestSuite() OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE) for testfile in ('testBrowserLayers.txt', 'testCustomizeView.txt'): suite.addTest(FunctionalDocFileSuite(testfile, optionflags=OPTIONFLAGS, package="plone.app.customerize.tests", test_class=CustomerizeFunctionalTestCase), ) return suite
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(sms_user)) suite.addTests(defaultTestLoader.loadTestsFromModule(notification)) suite.addTests(defaultTestLoader.loadTestsFromModule(reply)) suite.addTests(defaultTestLoader.loadTestsFromModule(registration)) return suite
def suite(): suite = TestSuite() suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestParseLine)) suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestFuzzyMatch)) if is_win: suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestAppIdentification)) return suite
def load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(OperatorsTest)) suite.addTest(loader.loadTestsFromTestCase(QueryCreationTest)) suite.addTest(loader.loadTestsFromTestCase(SearchTest)) return suite
def makeSuite(self): class TC(LiveWebServerSeleniumTestCase): def runTest(self): self.wd.get('http://%s:%s' % (LOCALHOST, self.webserver.port)) self.assertTrue(False) return TestSuite([TC()])
def makeSuite(self): class TC(SeleniumTestCase): def runTest(self): self.wd.get("http://google.com") self.assertEqual(self.wd.title, "Google") return TestSuite([TC()])
def get_suite(test_names, test_dir, file_match, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, found, failfast, debug, extended=False): suite = TestSuite() dir_list = os.listdir(test_dir) # filter directory entries that don't match the file match pattern dir_list = [f for f in dir_list if fnmatch.fnmatch(f, file_match)] for entry in dir_list: if not entry.endswith('.py'): continue if test_names and entry[:-3] not in test_names: continue elif not test_names: if entry.startswith('_'): # ignore entries starting with underscore unless specified continue found.add(entry[:-3]) csv_path = os.path.join(test_dir, entry.replace('.py', '.csv')) if os.path.isfile(csv_path): # reading the csv file now for row in get_data(csv_path): # row is a dictionary of variables suite.addTest( get_case( test_dir, entry, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, row, failfast=failfast, debug=debug, extended=extended ) ) else: suite.addTest( get_case( test_dir, entry, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast=failfast, debug=debug, extended=extended ) ) return suite
def allTest(): ''''' 创建测试集''' suite1 = TestLoader().loadTestsFromTestCase(login_case_ddt.LoginCase) suite2 = TestLoader().loadTestsFromTestCase( release_topic_case_ddt.ReleasdTopic) alltests = TestSuite([suite1, suite2]) return alltests
def makeSuite(self): class TC(LiveWebServerSeleniumTestCase): def runTest(self): self.wd.get('http://%s:%s' % (LOCALHOST, self.webserver.port)) self.wd.find_element_by_css_selector( "#this-does-not-exist").click() return TestSuite([TC()])
def suite(): suite = TestSuite() for test in make_json_suite(): for p in test['pass']: datum = json.loads(json.dumps(p.datum)) suite.addTest(make_pass(test['schema'], datum)) suite.addTest(make_reserialize(test['schema'], datum)) for f in test['fail']: datum = json.loads(json.dumps(f.datum)) suite.addTest(make_fail(test['schema'], datum)) return suite
def makeSuite(self): class TC(LiveWebServerSeleniumTestCase): def runTest(self): self.wd.get('http://%s:%s' % (LOCALHOST, self.webserver.port)) self.wd.implicitly_wait(0) ScreenshotOnExceptionWebDriverWait( self.wd, 10).until(lambda s: self.wd.find_element_by_css_selector( "#this-does-not-exist")) return TestSuite([TC()])
def suite(self): """ Inject generated tests """ GetTestCase.parent = self.parent GetTestCase.sdkobject = self.sdkobject GetTestCase.helper = self.helper tests = self.make_tests(sdkobject=self.sdkobject, testcase=GetTestCase) for test_name, test_func in tests.items(): setattr(GetTestCase, test_name, test_func) return TestSuite(list(map(GetTestCase, tests)))
def suite(self): """ Inject generated tests """ DeleteTestCase.parent = self.parent DeleteTestCase.sdkobject = self.sdkobject DeleteTestCase.helper = self.helper tests = self.make_tests(sdkobject=self.sdkobject, testcase=DeleteTestCase) for test_name, test_func in tests.iteritems(): setattr(DeleteTestCase, test_name, test_func) return TestSuite(map(DeleteTestCase, tests))
def get_suite(test_names, test_dir, collect_only, browser_type, device, version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast, debug, custom_options=None, extended=False, saucelabs_enabled=False, browserstack_enabled=False, vagrant_enabled=False, skip_tracking=False): suite = TestSuite() for case in find_cases(test_names, test_dir): csv_path = os.path.join(test_dir, case.replace('.py', '.csv')) if os.path.isfile(csv_path): # reading the csv file now for row in get_data(csv_path): # row is a dictionary of variables suite.addTest( get_case( test_dir, case, browser_type, device, version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, row, saucelabs_enabled=saucelabs_enabled, browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled, custom_options=custom_options, failfast=failfast, debug=debug, extended=extended, skip_tracking=skip_tracking ) ) else: suite.addTest( get_case( test_dir, case, browser_type, device, version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, custom_options=custom_options, failfast=failfast, browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled, debug=debug, extended=extended, saucelabs_enabled=saucelabs_enabled, skip_tracking=skip_tracking ) ) return suite
def get_suite(test_names, test_dir, count_only, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast, debug, extended=False): suite = TestSuite() if allscrewedup: print "ENTERING get_suite \n" print inspect.getargspec(get_suite) print [locals()[arg] for arg in inspect.getargspec(get_suite).args] for case in find_cases(test_names, test_dir): csv_path = os.path.join(test_dir, case.replace('.py', '.csv')) if os.path.isfile(csv_path): # reading the csv file now for row in get_data(csv_path): # row is a dictionary of variables suite.addTest( get_case( test_dir, case, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, row, failfast=failfast, debug=debug, extended=extended ) ) else: suite.addTest( get_case( test_dir, case, browser_type, browser_version, browser_platform, session_name, javascript_disabled, webdriver_remote_url, screenshots_on, failfast=failfast, debug=debug, extended=extended ) ) return suite
def load_tests(loader, standard_tests, pattern): """Loads the tests from this module""" suite = TestSuite() # Only enable if you have a local server running. # TODO: Consider automatic skipping if zmq fails to connect # suite.addTest(loader.loadTestsFromTestCase(LiveGuessApiTestCase)) suite.addTest(loader.loadTestsFromTestCase(ClientTestCase)) suite.addTest(loader.loadTestsFromTestCase(CORSTestCase)) return 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 load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(SimpleValidationTest)) suite.addTest(loader.loadTestsFromTestCase(SAVTest)) return suite
def load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(HelpersTest)) suite.addTest(loader.loadTestsFromTestCase(ModelHelpersTest)) return suite
def test_suite(): from unittest2 import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(PreconditionTests)) suite.addTest(makeSuite(PreconditionRegistryTests)) return suite
def suite(): s = TestSuite()
def suite(self): """ Returns a TestSuite that can be run TestSuite is computed according to what is defined in the specification """ all_suites = TestSuite() if self._create_allowed: maker = CreateTestMaker(self._sdk_parent_object, self._sdk_object, self._helper) suite = maker.suite() all_suites.addTests(suite) if self._update_allowed: maker = UpdateTestMaker(self._sdk_parent_object, self._sdk_object, self._helper) suite = maker.suite() all_suites.addTests(suite) if self._delete_allowed: maker = DeleteTestMaker(self._sdk_parent_object, self._sdk_object, self._helper) suite = maker.suite() all_suites.addTests(suite) if self._get_allowed: maker = GetTestMaker(self._sdk_parent_object, self._sdk_object, self._helper) suite = maker.suite() all_suites.addTests(suite) if self._get_all_allowed: maker = GetAllTestMaker(self._sdk_parent_object, self._sdk_object, self._helper) suite = maker.suite() all_suites.addTests(suite) return all_suites
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(models)) return suite
def test_suite(): from unittest2 import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(DepartmentTests)) return suite
def test_suite(): from unittest2 import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(BasicTests)) return suite
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(models)) suite.addTests(defaultTestLoader.loadTestsFromModule(new)) suite.addTests(defaultTestLoader.loadTestsFromModule(comments)) suite.addTests(defaultTestLoader.loadTestsFromModule(notification)) suite.addTests(defaultTestLoader.loadTestsFromModule(lists)) suite.addTests(defaultTestLoader.loadTestsFromModule(attendants)) suite.addTests(defaultTestLoader.loadTestsFromModule(invites)) return suite
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(server_running)) suite.addTests(defaultTestLoader.loadTestsFromModule(db)) suite.addTests(defaultTestLoader.loadTestsFromModule(users)) suite.addTests(defaultTestLoader.loadTestsFromModule(notification)) suite.addTests(defaultTestLoader.loadTestsFromModule(events)) suite.addTests(defaultTestLoader.loadTestsFromModule(SMS)) suite.addTests(defaultTestLoader.loadTestsFromModule(utils)) suite.addTests(defaultTestLoader.loadTestsFromModule(social)) return suite
def load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(ProcessorsTest)) return suite
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(generic_poll)) return suite
file_content = file.read() p = ast.parse(file_content) classes = [ node.name for node in ast.walk(p) if isinstance(node, ast.ClassDef) ] for cls in classes: # class_to_test = module_name + '.' + cls file_report_name = module_name + '_' + cls print(file_report_name) report_path = 'test/report/Report_' + file_report_name + '.html' f_load = open(report_path, 'w') f_load.close() runner = HTMLTestRunner( stream=open(report_path, "wb"), title="Unit Test Reports", description='This is Unit test report of system.') loader = TestLoader() m = importlib.import_module(module_name) # class_to_test = 'm.' + cls suite = TestSuite( (loader.loadTestsFromTestCase(getattr(m, cls)), )) # run the test runner.run(suite)
def suite(): import teleport_test, language_test main = defaultTestLoader.loadTestsFromModule(teleport_test) language = language_test.suite() return TestSuite([main, language])
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 test_suite(): from unittest2 import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(NumberMixinTests)) return suite
def makeSuite(self): class TC(TestCase): def runTest(self): raise ValueError("We should never get here") return TestSuite([TC()])
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 load_tests(loader, standard_tests, pattern): """Returns the test suite for this module.""" suite = TestSuite() suite.addTest(loader.loadTestsFromTestCase(APIManagerTest)) suite.addTest(loader.loadTestsFromTestCase(FSATest)) return suite
def load_tests(loader, tests, pattern): suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromModule(auth)) suite.addTests(defaultTestLoader.loadTestsFromModule(models)) suite.addTests(defaultTestLoader.loadTestsFromModule(requests)) suite.addTests(defaultTestLoader.loadTestsFromModule(following)) suite.addTests(defaultTestLoader.loadTestsFromModule(search)) return suite