How to use _set_test_name method in gabbi

Best Python code snippet using gabbi_python

suitemaker.py

Source:suitemaker.py Github

copy

Full Screen

...65 else:66 # NOTE(cdent): Not clear this can happen but just in case.67 raise GabbiFormatError(68 'malformed test chunk "%s": %s' % (test_dict, exc))69 test_name = self._set_test_name(test)70 self._set_test_method_and_url(test, test_name)71 self._validate_keys(test, test_name)72 # Set server hostname in http request if host header is set.73 if 'request_headers' in test and 'host' in test['request_headers']:74 hostname = test['request_headers']['host']75 else:76 hostname = None77 http_class = httpclient.get_http(verbose=test['verbose'],78 caption=test['name'],79 cert_validate=test['cert_validate'],80 hostname=hostname)81 if prior_test:82 history = prior_test.history83 else:84 history = {}85 test_method_name = 'test_request'86 test_method = getattr(case.HTTPTestCase, test_method_name)87 @unittest.skipIf(self.host == '', 'No host configured')88 @functools.wraps(test_method)89 def do_test(*args, **kwargs):90 return test_method(*args, **kwargs)91 # Use metaclasses to build a class of the necessary type92 # and name with relevant arguments.93 klass = TestBuilder(test_name, (case.HTTPTestCase,),94 {'test_data': test,95 'test_directory': self.test_directory,96 'fixtures': self.fixture_classes,97 'inner_fixtures': self.inner_fixtures,98 'http': http_class,99 'host': self.host,100 'intercept': self.intercept,101 'content_handlers': self.content_handlers,102 'response_handlers': self.response_handlers,103 'port': self.port,104 'prefix': self.prefix,105 'prior': prior_test,106 'history': history,107 'test_base_name': self.test_base_name,108 test_method_name: do_test,109 })110 # We've been asked to, make this test class think it comes111 # from a different module.112 if self.test_loader_name:113 klass.__module__ = self.test_loader_name114 tests = self.loader.loadTestsFromTestCase(klass)115 history[test['name']] = tests._tests[0]116 # Return the first (and only) test in the klass.117 return tests._tests[0]118 def _set_test_name(self, test):119 """Set the name of the test120 The original name is lowercased and spaces are replaces with '_'.121 The result is appended to the test_base_name, which is based on the122 name of the input data file.123 """124 if not test['name']:125 raise GabbiFormatError('Test name missing in a test in %s.'126 % self.test_base_name)127 return '%s_%s' % (self.test_base_name,128 test['name'].lower().replace(' ', '_'))129 @staticmethod130 def _set_test_method_and_url(test, test_name):131 """Extract the base URL and method for this test.132 If there is an upper case key in the test, that is used as the...

Full Screen

Full Screen

test_common.py

Source:test_common.py Github

copy

Full Screen

...44 # properly45 assert_greater(len(estimators), 0)46 for name, Estimator in estimators:47 # some can just not be sensibly default constructed48 yield (_set_test_name(check_parameters_default_constructible, name),49 name, Estimator)50def test_non_meta_estimators():51 # input validation etc for non-meta estimators52 estimators = all_estimators()53 for name, Estimator in estimators:54 if issubclass(Estimator, BiclusterMixin):55 continue56 if name.startswith("_"):57 continue58 for check in _yield_all_checks(name, Estimator):59 if issubclass(Estimator, ProjectedGradientNMF):60 # The ProjectedGradientNMF class is deprecated61 with ignore_warnings():62 yield _set_test_name(check, name), name, Estimator63 else:64 yield _set_test_name(check, name), name, Estimator65def test_configure():66 # Smoke test the 'configure' step of setup, this tests all the67 # 'configure' functions in the setup.pys in the scikit68 cwd = os.getcwd()69 setup_path = os.path.abspath(os.path.join(sklearn.__path__[0], '..'))70 setup_filename = os.path.join(setup_path, 'setup.py')71 if not os.path.exists(setup_filename):72 return73 try:74 os.chdir(setup_path)75 old_argv = sys.argv76 sys.argv = ['setup.py', 'config']77 clean_warning_registry()78 with warnings.catch_warnings():79 # The configuration spits out warnings when not finding80 # Blas/Atlas development headers81 warnings.simplefilter('ignore', UserWarning)82 if PY3:83 with open('setup.py') as f:84 exec(f.read(), dict(__name__='__main__'))85 else:86 execfile('setup.py', dict(__name__='__main__'))87 finally:88 sys.argv = old_argv89 os.chdir(cwd)90def test_class_weight_balanced_linear_classifiers():91 classifiers = all_estimators(type_filter='classifier')92 clean_warning_registry()93 with warnings.catch_warnings(record=True):94 linear_classifiers = [95 (name, clazz)96 for name, clazz in classifiers97 if ('class_weight' in clazz().get_params().keys() and98 issubclass(clazz, LinearClassifierMixin))]99 for name, Classifier in linear_classifiers:100 yield _set_test_name(check_class_weight_balanced_linear_classifier,101 name), name, Classifier102@ignore_warnings103def test_import_all_consistency():104 # Smoke test to check that any name in a __all__ list is actually defined105 # in the namespace of the module or package.106 pkgs = pkgutil.walk_packages(path=sklearn.__path__, prefix='sklearn.',107 onerror=lambda _: None)108 submods = [modname for _, modname, _ in pkgs]109 for modname in submods + ['sklearn']:110 if ".tests." in modname:111 continue112 package = __import__(modname, fromlist="dummy")113 for name in getattr(package, '__all__', ()):114 if getattr(package, name, None) is None:115 raise AttributeError(116 "Module '{0}' has no attribute '{1}'".format(117 modname, name))118def test_root_import_all_completeness():119 EXCEPTIONS = ('utils', 'tests', 'base', 'setup')120 for _, modname, _ in pkgutil.walk_packages(path=sklearn.__path__,121 onerror=lambda _: None):122 if '.' in modname or modname.startswith('_') or modname in EXCEPTIONS:123 continue124 assert_in(modname, sklearn.__all__)125def test_all_tests_are_importable():126 # Ensure that for each contentful subpackage, there is a test directory127 # within it that is also a subpackage (i.e. a directory with __init__.py)128 HAS_TESTS_EXCEPTIONS = re.compile(r'''(?x)129 \.externals(\.|$)|130 \.tests(\.|$)|131 \._132 ''')133 lookup = dict((name, ispkg)134 for _, name, ispkg135 in pkgutil.walk_packages(sklearn.__path__,136 prefix='sklearn.'))137 missing_tests = [name for name, ispkg in lookup.items()138 if ispkg139 and not HAS_TESTS_EXCEPTIONS.search(name)140 and name + '.tests' not in lookup]141 assert_equal(missing_tests, [],142 '{0} do not have `tests` subpackages. Perhaps they require '143 '__init__.py or an add_subpackage directive in the parent '144 'setup.py'.format(missing_tests))145def test_non_transformer_estimators_n_iter():146 # Test that all estimators of type which are non-transformer147 # and which have an attribute of max_iter, return the attribute148 # of n_iter atleast 1.149 for est_type in ['regressor', 'classifier', 'cluster']:150 regressors = all_estimators(type_filter=est_type)151 for name, Estimator in regressors:152 # LassoLars stops early for the default alpha=1.0 for153 # the iris dataset.154 if name == 'LassoLars':155 estimator = Estimator(alpha=0.)156 else:157 estimator = Estimator()158 if hasattr(estimator, "max_iter"):159 # These models are dependent on external solvers like160 # libsvm and accessing the iter parameter is non-trivial.161 if name in (['Ridge', 'SVR', 'NuSVR', 'NuSVC',162 'RidgeClassifier', 'SVC', 'RandomizedLasso',163 'LogisticRegressionCV']):164 continue165 # Tested in test_transformer_n_iter below166 elif (name in CROSS_DECOMPOSITION or167 name in ['LinearSVC', 'LogisticRegression']):168 continue169 else:170 # Multitask models related to ENet cannot handle171 # if y is mono-output.172 yield (_set_test_name(173 check_non_transformer_estimators_n_iter, name),174 name, estimator, 'Multi' in name)175def test_transformer_n_iter():176 transformers = all_estimators(type_filter='transformer')177 for name, Estimator in transformers:178 if issubclass(Estimator, ProjectedGradientNMF):179 # The ProjectedGradientNMF class is deprecated180 with ignore_warnings():181 estimator = Estimator()182 else:183 estimator = Estimator()184 # Dependent on external solvers and hence accessing the iter185 # param is non-trivial.186 external_solver = ['Isomap', 'KernelPCA', 'LocallyLinearEmbedding',187 'RandomizedLasso', 'LogisticRegressionCV']188 if hasattr(estimator, "max_iter") and name not in external_solver:189 if isinstance(estimator, ProjectedGradientNMF):190 # The ProjectedGradientNMF class is deprecated191 with ignore_warnings():192 yield _set_test_name(193 check_transformer_n_iter, name), name, estimator194 else:195 yield _set_test_name(196 check_transformer_n_iter, name), name, estimator197def test_get_params_invariance():198 # Test for estimators that support get_params, that199 # get_params(deep=False) is a subset of get_params(deep=True)200 # Related to issue #4465201 estimators = all_estimators(include_meta_estimators=False,202 include_other=True)203 for name, Estimator in estimators:204 if hasattr(Estimator, 'get_params'):205 # If class is deprecated, ignore deprecated warnings206 if hasattr(Estimator.__init__, "deprecated_original"):207 with ignore_warnings():208 yield _set_test_name(209 check_get_params_invariance, name), name, Estimator210 else:211 yield _set_test_name(...

Full Screen

Full Screen

bc_factory.py

Source:bc_factory.py Github

copy

Full Screen

...64 self._set_result(vertex)65 elif vertex.role.lower() == "topic":66 self._set_test_code(vertex)67 elif vertex.role.lower() == "qualifier.synonym.name":68 self._set_test_name(vertex)69 elif vertex.role.lower() == "qualifier.synonym.loinc":70 self._set_loinc_code(vertex)71 elif vertex.role.lower() == "qualifier.record" or vertex.role.lower() == "qualifier.variable" or \72 vertex.role.lower() == "qualifier.grouping":73 self._set_qualifier(vertex)74 else:75 #TODO check to see if it's an invalid role76 print(f"not processing role: {vertex.role}")77 except AttributeError:78 print(f"Concept {vertex.label} is missing the role attribute")79 def _set_qualifier(self, vertex):80 """81 for DECs with role qualifier set the BC attributes82 :param vertex: node object from the graph created using the CMAP83 """84 for node in vertex.target:85 if node[0].type == "Conceptual Domain":86 if node[0].ct_subset:87 self._qualifiers[vertex.label] = self._set_qualifier_subset(node[0].ct_subset)88 else:89 self._qualifiers[vertex.label] = node[0].label90 break91 def _set_qualifier_subset(self, subset):92 """93 return the name, c-code, and terms for a CT subset that defines a DEC CD (conceptual domain)94 :param subset: CT subset object that includes the list of terms95 :return: qualifier CT subset dictionary96 """97 qualifier_subset = {"name": subset.name, "c_code": subset.c_code}98 terms = []99 for term in subset.terms:100 term_label = term.label101 if term.is_default:102 term_label = term_label + " default"103 terms.append(term_label)104 qualifier_subset["terms"] = terms105 return qualifier_subset106 def _set_test_code(self, vertex):107 """108 sets the TESTCD and associated c-code for findings domain BCs; set to one value for the BC109 :param vertex: node object from the graph created using the CMAP110 """111 for node in vertex.target:112 if node[0].type == "Conceptual Domain":113 self.kwargs["test_cd"] = node[0].label.split("(")[0].strip()114 self.kwargs["test_c_code"] = node[0].label.split("(")[1].strip()[:-1]115 break116 def _set_test_name(self, vertex):117 """118 sets the test name for findings domain BCs; set to one value for the BC119 :param vertex: node object from the graph created using the CMAP120 """121 for node in vertex.target:122 if node[0].type == "Conceptual Domain":123 self.kwargs["test_name"] = node[0].label.split("(")[0].strip()124 break125 def _set_loinc_code(self, vertex):126 """127 sets the loinc code for findings domain BCs; set to one value for the BC128 :param vertex: node object from the graph created using the CMAP129 """130 for node in vertex.target:...

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 gabbi 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