How to use sample_with_prefixes method in hypothesis

Best Python code snippet using hypothesis

datetime.py

Source:datetime.py Github

copy

Full Screen

...367 # For details see https://github.com/HypothesisWorks/hypothesis/issues/2414368 strategy = sampled_from([key for key in available_timezones if valid_key(key)])369 if not allow_prefix:370 return strategy371 def sample_with_prefixes(zone):372 keys_with_prefixes = (zone, f"posix/{zone}", f"right/{zone}")373 return sampled_from([key for key in keys_with_prefixes if valid_key(key)])374 return strategy.flatmap(sample_with_prefixes)375@defines_strategy(force_reusable_values=True)376def timezones(*, no_cache: bool = False) -> SearchStrategy["zoneinfo.ZoneInfo"]:377 """A strategy for :class:`python:zoneinfo.ZoneInfo` objects.378 If ``no_cache=True``, the generated instances are constructed using379 :meth:`ZoneInfo.no_cache <python:zoneinfo.ZoneInfo.no_cache>` instead380 of the usual constructor. This may change the semantics of your datetimes381 in surprising ways, so only use it if you know that you need to!382 .. note::383 The :mod:`python:zoneinfo` module is new in Python 3.9, so you will need384 to install the :pypi:`backports.zoneinfo` module on earlier versions, and385 the :pypi:`importlib_resources` backport on Python 3.6....

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