How to use get_suite method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_filtersuite.py

Source:test_filtersuite.py Github

copy

Full Screen

...23 pass24 @classmethod25 def add_test(cls, name):26 setattr(cls, 'test_' + name, cls.runTest)27 def get_suite(self, name):28 try:29 suite = self.__cache[name]30 except KeyError:31 suite = self.__cache[name] = self.add_suite(32 name, self.__suites[name])33 return suite34 def add_suite(self, name, defs):35 if not defs:36 return unittest.TestSuite()37 elif isinstance(defs, list):38 return self.add_tests(name, defs)39 elif isinstance(defs, dict):40 return self.add_suites(name, defs)41 else:42 raise RuntimeError('invalid suite definition: %s' % defs)43 def add_suites(self, name, defs):44 return unittest.TestSuite(45 self.add_suite('_'.join((name, key)), value)46 for key, value in sorted(defs.items())47 )48 def add_tests(self, name, defs):49 class Test(self.Test):50 pass51 Test.__name__ = str('Test_' + name)52 for test_name in defs:53 Test.add_test(test_name)54 return unittest.defaultTestLoader.loadTestsFromTestCase(Test)55class FilterSuiteTestCaseVows(FilterSuiteTestCase):56 def test_returns_TestSuite_instance(self):57 suite = self.get_suite('empty')58 suite |should| be_instance_of(unittest.TestSuite)59 def test_creates_empty_suite_properly(self):60 suite = self.get_suite('empty')61 map(str, suite) |should| each_be_equal_to([])62 def test_creates_flat_suite_properly(self):63 suite = self.get_suite('flat')64 map(suite_str, suite) |should| each_be_equal_to([65 'test_one (Test_flat)',66 'test_three (Test_flat)',67 'test_two (Test_flat)',68 ])69 def test_creates_nested_suite_properly(self):70 suite = self.get_suite('nested')71 map(suite_str, suite) |should| each_be_equal_to([72 '<TestSuite tests=['73 '<Test_nested_first testMethod=test_one>, '74 '<Test_nested_first testMethod=test_two>]>',75 '<TestSuite tests=['76 '<Test_nested_second testMethod=test_four>, '77 '<Test_nested_second testMethod=test_three>]>',78 ]) # noqa79 def test_creates_mixed_suite_properly(self):80 suite = self.get_suite('mixed')81 map(suite_str, suite) |should| each_be_equal_to([82 '<TestSuite tests=['83 '<Test_mixed_flat testMethod=test_one>, '84 '<Test_mixed_flat testMethod=test_two>]>',85 '<TestSuite tests=['86 '<TestSuite tests=['87 '<Test_mixed_nested_first testMethod=test_four>, '88 '<Test_mixed_nested_first testMethod=test_three>]>, '89 '<TestSuite tests=['90 '<Test_mixed_nested_second testMethod=test_five>, '91 '<Test_mixed_nested_second testMethod=test_six>]>, '92 '<TestSuite tests=['93 '<TestSuite tests=['94 '<Test_mixed_nested_third_deep testMethod=test_eight>, ' # noqa95 '<Test_mixed_nested_third_deep testMethod=test_seven>]>]>]>', # noqa96 ]) # noqa97class FlattenSuiteVows(FilterSuiteTestCase):98 def test_returns_TestSuite_instance(self):99 suite = self.get_suite('empty')100 flattened = flatten_suite(suite)101 flattened |should| be_instance_of(unittest.TestSuite)102 def test_handles_empty_suite_properly(self):103 suite = self.get_suite('empty')104 flattened = flatten_suite(suite)105 next = partial(six.next, iter(flattened))106 next |should| throw(StopIteration)107 def test_handles_flat_suite_properly(self):108 suite = self.get_suite('flat')109 flattened = flatten_suite(suite)110 map(suite_str, flattened) |should| each_be_equal_to([111 'test_one (Test_flat)',112 'test_three (Test_flat)',113 'test_two (Test_flat)',114 ])115 def test_flattens_nested_suite_properly(self):116 suite = self.get_suite('nested')117 flattened = flatten_suite(suite)118 map(suite_str, flattened) |should| each_be_equal_to([119 'test_one (Test_nested_first)',120 'test_two (Test_nested_first)',121 'test_four (Test_nested_second)',122 'test_three (Test_nested_second)',123 ])124 def test_flattens_mixed_suite_properly(self):125 suite = self.get_suite('mixed')126 flattened = flatten_suite(suite)127 map(suite_str, flattened) |should| each_be_equal_to([128 'test_one (Test_mixed_flat)',129 'test_two (Test_mixed_flat)',130 'test_four (Test_mixed_nested_first)',131 'test_three (Test_mixed_nested_first)',132 'test_five (Test_mixed_nested_second)',133 'test_six (Test_mixed_nested_second)',134 'test_eight (Test_mixed_nested_third_deep)',135 'test_seven (Test_mixed_nested_third_deep)',136 ])137@mock.patch('autocheck.db.Database')138class FilterSuiteVows(FilterSuiteTestCase):139 def test_returns_TestSuite_instance(self, Database):140 suite = self.get_suite('flat')141 candidates = list(map(str, suite))[:1]142 db = Database()143 db.candidates = mock.Mock('candidates', return_value=set(candidates))144 filtered, full_suite = filter_suite(suite, db)145 filtered |should| be_instance_of(unittest.TestSuite)146 def test_returns_all_tests_when_there_is_no_database(self, Database):147 suite = self.get_suite('flat')148 filtered, full_suite = filter_suite(suite, None)149 full_suite |should| be(True)150 map(str, filtered) |should| each_be_equal_to(map(str, suite))151 def test_returns_all_tests_when_candidates_empty(self, Database):152 suite = self.get_suite('flat')153 db = Database()154 db.candidates = mock.Mock('candidates', return_value=set())155 filtered, full_suite = filter_suite(suite, db)156 full_suite |should| be(True)157 map(str, filtered) |should| each_be_equal_to(map(str, suite))158 def test_returns_only_tests_that_are_candidates_if_there_are_candidates(self, Database): # noqa159 suite = self.get_suite('flat')160 candidates = ['test_two (%s.Test_flat)' % __name__]161 db = Database()162 db.candidates = mock.Mock('candidates', return_value=set(candidates))163 filtered, full_suite = filter_suite(suite, db)164 full_suite |should| be(False)165 map(str, filtered) |should| each_be_equal_to(candidates)166 def test_returns_all_tests_when_filtered_empty(self, Database):167 suite = self.get_suite('flat')168 candidates = ['unknown']169 db = Database()170 db.candidates = mock.Mock('candidates', return_value=set(candidates))171 filtered, full_suite = filter_suite(suite, db)172 full_suite |should| be(True)173 map(str, filtered) |should| each_be_equal_to(map(str, suite))174def suite_str(suite):175 return re.sub(176 r'unittest2?\.suite\.', '', str(suite)).replace(__name__ + '.', '')177#................................................................................

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...25 suite.addTest(doctest.DocTestSuite(mod))26 suite.addTest(doctest.DocFileSuite('../../index.rst'))27 return suite28def all_tests_suite():29 def get_suite():30 return additional_tests(31 unittest.TestLoader().loadTestsFromNames([32 'simplejson.tests.test_bitsize_int_as_string',33 'simplejson.tests.test_bigint_as_string',34 'simplejson.tests.test_check_circular',35 'simplejson.tests.test_decode',36 'simplejson.tests.test_default',37 'simplejson.tests.test_dump',38 'simplejson.tests.test_encode_basestring_ascii',39 'simplejson.tests.test_encode_for_html',40 'simplejson.tests.test_errors',41 'simplejson.tests.test_fail',42 'simplejson.tests.test_float',43 'simplejson.tests.test_indent',44 'simplejson.tests.test_pass1',45 'simplejson.tests.test_pass2',46 'simplejson.tests.test_pass3',47 'simplejson.tests.test_recursion',48 'simplejson.tests.test_scanstring',49 'simplejson.tests.test_separators',50 'simplejson.tests.test_speedups',51 'simplejson.tests.test_unicode',52 'simplejson.tests.test_decimal',53 'simplejson.tests.test_tuple',54 'simplejson.tests.test_namedtuple',55 'simplejson.tests.test_tool',56 'simplejson.tests.test_for_json',57 ]))58 suite = get_suite()59 import simplejson60 if simplejson._import_c_make_encoder() is None:61 suite.addTest(TestMissingSpeedups())62 else:63 suite = unittest.TestSuite([64 suite,65 NoExtensionTestSuite([get_suite()]),66 ])67 return suite68def main():69 runner = unittest.TextTestRunner(verbosity=1 + sys.argv.count('-v'))70 suite = all_tests_suite()71 raise SystemExit(not runner.run(suite).wasSuccessful())72if __name__ == '__main__':73 import os74 import sys75 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))...

Full Screen

Full Screen

test_runner.py

Source:test_runner.py Github

copy

Full Screen

...10import test_operator11import test_hypersphere12loader = unittest.TestLoader()13suite = unittest.TestSuite()14suite.addTest(test_recompose.get_suite())15suite.addTest(test_find_basis.get_suite())16suite.addTest(test_utils.get_suite())17suite.addTest(test_matrix_ln.get_suite())18suite.addTest(test_diagonalize.get_suite())19suite.addTest(test_compose.get_suite())20suite.addTest(test_similarity_matrix.get_suite())21suite.addTest(test_simplify.get_suite())22suite.addTest(test_operator.get_suite())23suite.addTest(test_hypersphere.get_suite())...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful