How to use _get_metadata_next_rank method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

loader.py

Source:loader.py Github

copy

Full Screen

...158 suite = Suite(mod, suite_name, suite_description)159 suite.tags.extend(suite_info.get("tags", []))160 suite.properties.update(suite_info.get("properties", {}))161 suite.links.extend(map(_normalize_link, suite_info.get("links", [])))162 suite.rank = suite_info.get("rank", _get_metadata_next_rank())163 suite.hidden = suite_condition and not suite_condition(mod)164 try:165 _check_test_tree_node_types(suite)166 except TypeError as excp:167 raise SuiteLoadingError("Invalid suite metadata type for '%s': %s" % (suite.name, excp))168 for hook_name in SUITE_HOOKS:169 if hasattr(mod, hook_name):170 suite.add_hook(hook_name, getattr(mod, hook_name))171 for test in _load_tests(_get_test_functions_from_module(mod)):172 suite.add_test(test)173 for test in _get_generated_tests(mod):174 suite.add_test(test)175 for sub_suite in load_suites_from_classes(_get_suite_classes_from_module(mod)):176 suite.add_suite(sub_suite)...

Full Screen

Full Screen

builder.py

Source:builder.py Github

copy

Full Screen

...21 self.dependencies = []22 self.disabled = False23 self.condition = None24 self.parametrized = None25def _get_metadata_next_rank():26 rank = Metadata._next_rank27 Metadata._next_rank += 128 return rank29def build_description_from_name(name):30 return name.capitalize().replace("_", " ")31def add_test_into_suite(test, suite):32 # type: (Test, Any) -> None33 """34 Add test into suite35 :param test: a :py:class:`Test <lemoncheesecake.suite.core.Test>` instance36 :param suite: a suite decorated class instance (in that case the function must be37 called when the class is instantiated) or a module marked as a suite (in that case the function38 must be called when the module is loaded)39 """40 if not hasattr(suite, "_lccgeneratedtests"):41 suite._lccgeneratedtests = []42 if test.rank is None:43 test.rank = _get_metadata_next_rank()44 suite._lccgeneratedtests.append(test)45_objects_with_metadata = []46def get_metadata(obj):47 global _objects_with_metadata48 if hasattr(obj, "_lccmetadata"):49 if obj not in _objects_with_metadata: # metadata comes from the superclass50 obj._lccmetadata = copy.deepcopy(obj._lccmetadata)51 return obj._lccmetadata52 else:53 obj._lccmetadata = Metadata()54 _objects_with_metadata.append(obj)55 return obj._lccmetadata56def suite(description=None, name=None, rank=None):57 """58 Decorator, mark a class as a suite class.59 :param description: suite's description (by default, the suite's description is built from the name)60 :param name: suite's name (by default, the suite's name is taken from the class's name)61 :param rank: this value is used to order suites of the same hierarchy level62 """63 def wrapper(klass):64 assert inspect.isclass(klass), "%s is not a class (suite decorator can only be used on a class)" % klass65 md = get_metadata(klass)66 assert not md.dependencies, "'depends_on' can not be used on a suite class"67 md.is_suite = True68 md.rank = rank if rank is not None else _get_metadata_next_rank()69 md.name = name or klass.__name__70 md.description = description or build_description_from_name(md.name)71 return klass72 return wrapper73def test(description=None, name=None):74 """75 Decorator, mark a function/method as a test.76 :param description: test's description77 :param name: test's name (by default, the suite's name is taken from the class's name)78 """79 def wrapper(func):80 assert inspect.isfunction(func), "%s is not a function (test decorator can only be used on a function)" % func81 md = get_metadata(func)82 md.is_test = True83 md.rank = _get_metadata_next_rank()84 md.name = name or func.__name__85 md.description = description or build_description_from_name(md.name)86 return func87 return wrapper88def tags(*tag_names):89 """Decorator, add tags to a test or a suite."""90 def wrapper(obj):91 md = get_metadata(obj)92 md.tags.extend(tag_names)93 return obj94 return wrapper95def prop(key, value):96 """Decorator, add a property (key/value) to a test or a suite."""97 def wrapper(obj):...

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