我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用unittest.makeSuite()。
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(AssociateErrorTestCase)) suite.addTest(unittest.makeSuite(AssociateHashTestCase)) suite.addTest(unittest.makeSuite(AssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(AssociateRecnoTestCase)) suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase)) if have_threads: suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase)) suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase)) return suite
def suite(): setup_path() suite = unittest.TestSuite() try: from minitwit_tests import MiniTwitTestCase except ImportError: pass else: suite.addTest(unittest.makeSuite(MiniTwitTestCase)) try: from flaskr_tests import FlaskrTestCase except ImportError: pass else: suite.addTest(unittest.makeSuite(FlaskrTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ExtImportHookTestCase)) return suite
def test_suite(): from zope.testing import doctest suite = unittest.makeSuite(InterfaceTests) suite.addTest(doctest.DocTestSuite("zope.interface.interface")) if sys.version_info >= (2, 4): suite.addTest(doctest.DocTestSuite()) suite.addTest(doctest.DocFileSuite( '../README.txt', globs={'__name__': '__main__'}, optionflags=doctest.NORMALIZE_WHITESPACE, )) suite.addTest(doctest.DocFileSuite( '../README.ru.txt', globs={'__name__': '__main__'}, optionflags=doctest.NORMALIZE_WHITESPACE, )) return suite
def test_suite(): suite = unittest.TestSuite() if have_threads: suite.addTest(unittest.makeSuite(BTreeConcurrentDataStore)) suite.addTest(unittest.makeSuite(HashConcurrentDataStore)) suite.addTest(unittest.makeSuite(BTreeSimpleThreaded)) suite.addTest(unittest.makeSuite(HashSimpleThreaded)) suite.addTest(unittest.makeSuite(BTreeThreadedTransactions)) suite.addTest(unittest.makeSuite(HashThreadedTransactions)) suite.addTest(unittest.makeSuite(BTreeThreadedNoWaitTransactions)) suite.addTest(unittest.makeSuite(HashThreadedNoWaitTransactions)) else: print "Threads not available, skipping thread tests." return suite
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(VersionTestCase)) suite.addTest(unittest.makeSuite(BasicBTreeTestCase)) suite.addTest(unittest.makeSuite(BasicHashTestCase)) suite.addTest(unittest.makeSuite(BasicBTreeWithThreadFlagTestCase)) suite.addTest(unittest.makeSuite(BasicHashWithThreadFlagTestCase)) suite.addTest(unittest.makeSuite(BasicBTreeWithEnvTestCase)) suite.addTest(unittest.makeSuite(BasicHashWithEnvTestCase)) suite.addTest(unittest.makeSuite(BTreeTransactionTestCase)) suite.addTest(unittest.makeSuite(HashTransactionTestCase)) suite.addTest(unittest.makeSuite(BTreeRecnoTestCase)) suite.addTest(unittest.makeSuite(BTreeRecnoWithThreadFlagTestCase)) suite.addTest(unittest.makeSuite(BTreeDUPTestCase)) suite.addTest(unittest.makeSuite(HashDUPTestCase)) suite.addTest(unittest.makeSuite(BTreeDUPWithThreadTestCase)) suite.addTest(unittest.makeSuite(HashDUPWithThreadTestCase)) suite.addTest(unittest.makeSuite(BTreeMultiDBTestCase)) suite.addTest(unittest.makeSuite(HashMultiDBTestCase)) suite.addTest(unittest.makeSuite(DBEnvPrivateObject)) suite.addTest(unittest.makeSuite(DBPrivateObject)) suite.addTest(unittest.makeSuite(CrashAndBurn)) return suite
def run_unittest(*classes): """Run tests from unittest.TestCase-derived classes.""" valid_types = (unittest.TestSuite, unittest.TestCase) suite = unittest.TestSuite() for cls in classes: if isinstance(cls, str): if cls in sys.modules: suite.addTest(unittest.findTestCases(sys.modules[cls])) else: raise ValueError("str arguments must be keys in sys.modules") elif isinstance(cls, valid_types): suite.addTest(cls) else: suite.addTest(unittest.makeSuite(cls)) _run_suite(suite) #======================================================================= # doctest driver.
def main(): """Runs the unit tests""" suite = unittest.TestSuite() suite.addTests(unittest.makeSuite(TestFunctions)) suite.addTests(unittest.makeSuite(TestPointCharge)) suite.addTests(unittest.makeSuite(TestLineCharge)) suite.addTests(unittest.makeSuite(TestElectricField)) suite.addTests(unittest.makeSuite(TestGaussianCircle)) result = unittest.TextTestRunner(verbosity=1).run(suite) n_errors = len(result.errors) n_failures = len(result.failures) if n_errors or n_failures: print('\n\nSummary: %d errors and %d failures reported\n'%\ (n_errors, n_failures)) print() sys.exit(n_errors+n_failures)
def test(): import QuantLib print('testing QuantLib ' + QuantLib.__version__) suite = unittest.TestSuite() suite.addTest(DateTest()) suite.addTest(DayCountersTest()) suite.addTest(unittest.makeSuite(InstrumentTest,'test')) suite.addTest(unittest.makeSuite(MarketElementTest,'test')) suite.addTest(unittest.makeSuite(IntegralTest,'test')) suite.addTest(Solver1DTest()) suite.addTest(unittest.makeSuite(TermStructureTest,'test')) suite.addTest(unittest.makeSuite(FixedRateBondTest, 'test')) suite.addTest(unittest.makeSuite(FixedRateBondHelperTest, 'test')) suite.addTest(unittest.makeSuite(CmsTest, 'test')) suite.addTest(unittest.makeSuite(AssetSwapTest, 'test')) suite.addTest(unittest.makeSuite(CapFloorTest, 'test')) result = unittest.TextTestRunner(verbosity=2).run(suite) if not result.wasSuccessful: sys.exit(1)
def buildtestsuite(recurse=True): from enchant.checker.tests import TestChecker from enchant.tokenize.tests import TestTokenization, TestFilters from enchant.tokenize.tests import TestTokenizeEN suite = unittest.TestSuite() if recurse: suite.addTest(unittest.makeSuite(TestInstallEnv)) suite.addTest(unittest.makeSuite(TestPy2exe)) suite.addTest(unittest.makeSuite(TestBroker)) suite.addTest(unittest.makeSuite(TestDict)) suite.addTest(unittest.makeSuite(TestPWL)) suite.addTest(unittest.makeSuite(TestUtils)) suite.addTest(unittest.makeSuite(TestDocStrings)) suite.addTest(unittest.makeSuite(TestChecker)) suite.addTest(unittest.makeSuite(TestTokenization)) suite.addTest(unittest.makeSuite(TestTokenizeEN)) suite.addTest(unittest.makeSuite(TestFilters)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(MarkupTestCase)) # this test only tests the c extension if not hasattr(escape, 'func_code'): suite.addTest(unittest.makeSuite(MarkupLeakTestCase)) return suite
def suite(): suite = unittest.TestSuite() for testclass in _testclasses(): suite.addTest(unittest.makeSuite(testclass)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEmailAsianCodecs)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(DeprecationsTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestToolsTestCase)) suite.addTest(unittest.makeSuite(SubdomainTestCase)) return suite
def suite(): suite = unittest.TestSuite() if flask.json_available: suite.addTest(unittest.makeSuite(JSONTestCase)) suite.addTest(unittest.makeSuite(SendfileTestCase)) suite.addTest(unittest.makeSuite(LoggingTestCase)) suite.addTest(unittest.makeSuite(NoImportsTestCase)) suite.addTest(unittest.makeSuite(StreamingTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ViewTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(BlueprintTestCase)) suite.addTest(unittest.makeSuite(ModuleTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(BasicFunctionalityTestCase)) suite.addTest(unittest.makeSuite(SubdomainTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TemplatingTestCase)) return suite
def suite(): suite = unittest.TestSuite() if flask.signals_available: suite.addTest(unittest.makeSuite(SignalsTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(RequestContextTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(FlaskSubclassingTestCase)) return suite
def suite(): suite = unittest.TestSuite() if os.environ.get('RUN_FLASK_MEMORY_TESTS') == '1': suite.addTest(unittest.makeSuite(MemoryTestCase)) suite.addTest(unittest.makeSuite(ExceptionTestCase)) return suite
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ConfigTestCase)) suite.addTest(unittest.makeSuite(InstanceTestCase)) return suite
def test_suite(): return unittest.makeSuite(TestDevelopTest)
def suite(): suites = [ShapeGraphCase, BonusCase] suite = unittest.TestSuite() for s in suites: suite.addTest(unittest.makeSuite(s)) return suite
def getTests(filterApplication=""): root = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs")) suites = {} for root, dirs, files in os.walk(root): for file in files: if file.startswith("__") or file.endswith(".pyc") or not file.lower().startswith("test"): logger.debug("skipping file for testing {}".format(file)) continue name = os.path.splitext(os.path.basename(os.path.join(root, file)))[0] try: module = imp.load_source(name, os.path.realpath(os.path.join(root, file))) except ImportError as e: logger.info("import failed for {}".format(file), exc_info=True) continue for member in inspect.getmembers(module, predicate=inspect.isclass): cl = member[1] try: app = cl.application except AttributeError: logger.debug("class not a test skipping :{}".format(cl)) continue if app in suites: suites[app].addTest(unittest.makeSuite(cl)) continue if not filterApplication: newSuite = unittest.makeSuite(cl) suites[app] = newSuite elif app == filterApplication: newSuite = unittest.makeSuite(cl) suites[app] = newSuite return suites
def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(AppContextTestCase)) return suite
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test)) suite.addTest(DocTestSuite("zope.interface.declarations")) suite.addTest(DocTestSuite()) return suite
def test_suite(): return makeSuite(Test)
def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test)) return suite