How to use describe_close_matches method in hypothesis

Best Python code snippet using hypothesis

cli.py

Source:cli.py Github

copy

Full Screen

...84 raise click.UsageError(85 f"Failed to import the {modulename} module for introspection. "86 "Check spelling and your Python import path, or use the Python API?"87 ) from err88 def describe_close_matches(89 module_or_class: types.ModuleType, objname: str90 ) -> str:91 public_names = [92 name for name in vars(module_or_class) if not name.startswith("_")93 ]94 matches = get_close_matches(objname, public_names)95 if matches:96 return f" Closest matches: {matches!r}"97 else:98 return ""99 if classname is None:100 try:101 return getattr(module, funcname)102 except AttributeError as err:103 raise click.UsageError(104 f"Found the {modulename!r} module, but it doesn't have a "105 f"{funcname!r} attribute."106 + describe_close_matches(module, funcname)107 ) from err108 else:109 try:110 func_class = getattr(module, classname)111 except AttributeError as err:112 raise click.UsageError(113 f"Found the {modulename!r} module, but it doesn't have a "114 f"{classname!r} class." + describe_close_matches(module, classname)115 ) from err116 try:117 return getattr(func_class, funcname)118 except AttributeError as err:119 if inspect.isclass(func_class):120 func_class_is = "class"121 else:122 func_class_is = "attribute"123 raise click.UsageError(124 f"Found the {modulename!r} module and {classname!r} {func_class_is}, "125 f"but it doesn't have a {funcname!r} attribute."126 + describe_close_matches(func_class, funcname)127 ) from err128 def _refactor(func, fname):129 try:130 with open(fname) as f:131 oldcode = f.read()132 except (OSError, UnicodeError) as err:133 # Permissions or encoding issue, or file deleted, etc.134 return f"skipping {fname!r} due to {err}"135 newcode = func(oldcode)136 if newcode != oldcode:137 with open(fname, mode="w") as f:138 f.write(newcode)139 @main.command() # type: ignore # Click adds the .command attribute140 @click.argument("path", type=str, required=True, nargs=-1)...

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