Best Python code snippet using tavern
testutil.py
Source:testutil.py
...28 def __init__(self, name, parent, spec):29 ep("Yaml Item")30 super(YamlItem, self).__init__(name, parent)31 self.spec = spec32 def repr_failure(self, excinfo):33 """ called when self.runtest() raises an exception. """34 if isinstance(excinfo.value, YamlException):35 return "\n".join([36 "usecase execution failed",37 " spec failed: %r: %r" % excinfo.value.args[1:3],38 " no further details known at this point."39 ])40 # else:41 # ep("weird failure instance")42 # ep("repr_failure with othe exc:")43 # ep(pformat(excinfo))44 # return "fuckoff"45 def reportinfo(self):46 return self.fspath, 0, "usecase: %s" % self.name...
pytest_bare_type_ignore.py
Source:pytest_bare_type_ignore.py
...16 def runtest(self):17 errors = list(self._check_file(self.fspath))18 if errors:19 raise BTIError('\n'.join(errors))20 def repr_failure(self, excinfo, style=None):21 if excinfo.errisinstance(BTIError):22 return excinfo.value.args[0]23 return super().repr_failure(excinfo)24 def _check_file(self, path):25 tree = ast.parse(path.read(), type_comments=True)26 visitor = Visitor()27 visitor.visit(tree)28 yield from visitor.errors29class Visitor(ast.NodeVisitor):30 def __init__(self) -> None:31 self.errors: List[str] = []32 def visit_TypeIgnore(self, node: ast.TypeIgnore) -> None:33 if not node.tag:34 self.errors.append(f"Line {node.lineno}: '#type: ignore' without tag")...
pytest_jsonlint.py
Source:pytest_jsonlint.py
...16 data = fp.read()17 results = demjson.decode(data, return_errors=True)18 if len(results.errors) > 0:19 raise JSONError(results.errors)20 def repr_failure(self, excinfo):21 if excinfo.errisinstance(JSONError):22 return '\n'.join(23 '%s - %s' % (err.message,err.position)24 for err in excinfo.value.errors[:10]25 )26 return super().repr_failure(excinfo)27 def reportinfo(self):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!