How to use _stash_get method in hypothesis

Best Python code snippet using hypothesis

_hypothesis_pytestplugin.py

Source:_hypothesis_pytestplugin.py Github

copy

Full Screen

...233 with current_pytest_item.with_value(item):234 yield235 if store.results:236 item.hypothesis_report_information = list(store.results)237 def _stash_get(config, key, default):238 if hasattr(config, "stash"):239 # pytest 7240 return config.stash.get(key, default)241 elif hasattr(config, "_store"):242 # pytest 5.4243 return config._store.get(key, default)244 else:245 return getattr(config, key, default)246 @pytest.hookimpl(hookwrapper=True)247 def pytest_runtest_makereport(item, call):248 report = (yield).get_result()249 if hasattr(item, "hypothesis_report_information"):250 report.sections.append(251 ("Hypothesis", "\n".join(item.hypothesis_report_information))252 )253 if hasattr(item, "hypothesis_statistics") and report.when == "teardown":254 stats = item.hypothesis_statistics255 stats_base64 = base64.b64encode(stats.encode()).decode()256 name = "hypothesis-statistics-" + item.nodeid257 # Include hypothesis information to the junit XML report.258 #259 # Note that when `pytest-xdist` is enabled, `xml_key` is not present in the260 # stash, so we don't add anything to the junit XML report in that scenario.261 # https://github.com/pytest-dev/pytest/issues/7767#issuecomment-1082436256262 xml = _stash_get(item.config, xml_key, None)263 if xml:264 xml.add_global_property(name, stats_base64)265 # If there's a terminal report, include our summary stats for each test266 terminalreporter = item.config.pluginmanager.getplugin("terminalreporter")267 if terminalreporter is not None:268 # ideally, we would store this on terminalreporter.config.stash, but269 # pytest-xdist doesn't copy that back to the controller270 report.__dict__[STATS_KEY] = stats271 # If there's an HTML report, include our summary stats for each test272 pytest_html = item.config.pluginmanager.getplugin("html")273 if pytest_html is not None: # pragma: no cover274 report.extra = getattr(report, "extra", []) + [275 pytest_html.extras.text(stats, name="Hypothesis stats")276 ]...

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