Best Python code snippet using pytest
expression.py
Source:expression.py
...118 rhs = and_expr(s)119 ret = ast.BoolOp(ast.Or(), [ret, rhs])120 return ret121def and_expr(s: Scanner) -> ast.expr:122 ret = not_expr(s)123 while s.accept(TokenType.AND):124 rhs = not_expr(s)125 ret = ast.BoolOp(ast.And(), [ret, rhs])126 return ret127def not_expr(s: Scanner) -> ast.expr:128 if s.accept(TokenType.NOT):129 return ast.UnaryOp(ast.Not(), not_expr(s))130 if s.accept(TokenType.LPAREN):131 ret = expr(s)132 s.accept(TokenType.RPAREN, reject=True)133 return ret134 ident = s.accept(TokenType.IDENT)135 if ident:136 return ast.Name(IDENT_PREFIX + ident.value, ast.Load())137 s.reject((TokenType.NOT, TokenType.LPAREN, TokenType.IDENT))138class MatcherAdapter(Mapping[str, bool]):139 """Adapts a matcher function to a locals mapping as required by eval()."""140 def __init__(self, matcher: Callable[[str], bool]) -> None:141 self.matcher = matcher142 def __getitem__(self, key: str) -> bool:143 return self.matcher(key[len(IDENT_PREFIX) :])...
not_op.py
Source:not_op.py
1# encoding: utf-82#3#4# This Source Code Form is subject to the terms of the Mozilla Public5# License, v. 2.0. If a copy of the MPL was not distributed with this file,6# You can obtain one at http:# mozilla.org/MPL/2.0/.7#8# Contact: Kyle Lahnakoski (kyle@lahnakoski.com)9#10from __future__ import absolute_import, division, unicode_literals11from jx_base.expressions import NotOp as NotOp_12from jx_base.language import is_op13from jx_bigquery.expressions._utils import check14from jx_bigquery.expressions.boolean_op import BooleanOp15from mo_dots import wrap16from mo_sql import sql_iso17class NotOp(NotOp_):18 @check19 def to_bq(self, schema, not_null=False, boolean=False):20 not_expr = NotOp(BooleanOp(self.term)).partial_eval()21 if is_op(not_expr, NotOp):22 return wrap(23 [24 {25 "name": ".",26 "sql": {27 "b": "NOT " + sql_iso(not_expr.term.to_bq(schema)[0].sql.b)28 },29 }30 ]31 )32 else:...
Looking for an in-depth tutorial around pytest? LambdaTest covers the detailed pytest tutorial that has everything related to the pytest, from setting up the pytest framework to automation testing. Delve deeper into pytest testing by exploring advanced use cases like parallel testing, pytest fixtures, parameterization, executing multiple test cases from a single file, and more.
Skim our below pytest tutorial playlist to get started with automation testing using the pytest framework.
https://www.youtube.com/playlist?list=PLZMWkkQEwOPlcGgDmHl8KkXKeLF83XlrP
Get 100 minutes of automation test minutes FREE!!