Best Python code snippet using pyshould_python
test_json_matcher.py
Source:test_json_matcher.py
...88 matcher = json_matcher.compile('A:ìë
B:ì¸ìì', json_matcher.IMPLICIT_AND)89 assert not matcher.match(dict(A='ìë
'))90 assert not matcher.match(dict(B='ì¸ìì'))91 assert matcher.match(dict(A='ìë
', B='ì¸ìì'))92def test_implicit_or():93 matcher = json_matcher.compile('A:ìë
B:ì¸ìì', json_matcher.IMPLICIT_OR)94 assert matcher.match(dict(A='ìë
'))95 assert matcher.match(dict(B='ì¸ìì'))96 assert matcher.match(dict(A='ìë
', B='ì¸ìì'))97def test_match_result():98 # OR => short circuit99 matcher = json_matcher.compile('A:ìë
B:ì¸ìì', json_matcher.IMPLICIT_OR)100 r = matcher.match(dict(A='ìë
', B='ì¸ìì'))101 l = r.groups()102 assert len(l) == 1103 assert l[0] == ('A', 'ìë
')104 matcher = json_matcher.compile('A:ìë
B:ì¸ìì', json_matcher.IMPLICIT_AND)105 r = matcher.match(dict(A='ìë
', B='ì¸ìì'))106 l = r.groups()...
test_expression.py
Source:test_expression.py
...41 def test_parens(self):42 expr = 'not (x and y)'43 postfix = list(expression.build_postfix_expression(expr))44 assert postfix == ['x', 'y', 'and', 'not']45 def test_implicit_or(self):46 expr = 'x y'47 postfix = list(expression.build_postfix_expression(expr))48 assert postfix == ['x', 'y', 'or']49 expr = 'x y z'50 postfix = list(expression.build_postfix_expression(expr))51 assert postfix == ['x', 'y', 'or', 'z', 'or']52 expr = '(x y) z'53 postfix = list(expression.build_postfix_expression(expr))54 assert postfix == ['x', 'y', 'or', 'z', 'or']55 expr = 'x (y or z)'56 postfix = list(expression.build_postfix_expression(expr))57 assert postfix == ['x', 'y', 'z', 'or', 'or']58class TestBuildExprFromPostfix:59 def test_binary(self):60 postfix = ['x', 'y', 'or']61 result = expression.build_expr_from_postfix(postfix)62 query = Or((RegexQuery.from_string('y'),63 RegexQuery.from_string('x')))64 assert result == query65 postfix = ['x', 'y', 'and']66 result = expression.build_expr_from_postfix(postfix)67 query = And((RegexQuery.from_string('y'),68 RegexQuery.from_string('x')))69 assert result == query70 def test_unary(self):71 postfix = ['x', 'not']72 result = expression.build_expr_from_postfix(postfix)73 query = Not(RegexQuery.from_string('x'))74 assert result == query75 def test_single(self):76 postfix = ['x']77 result = expression.build_expr_from_postfix(postfix)78 query = RegexQuery.from_string('x')79 assert result == query80 def test_payee(self):81 postfix = ['x', 'payee']82 result = expression.build_expr_from_postfix(postfix)83 query = PayeeQuery(RegexQuery.from_string('x'))84 assert result == query85 def test_payee_at(self):86 postfix = ['x', '@']87 result = expression.build_expr_from_postfix(postfix)88 query = PayeeQuery(RegexQuery.from_string('x'))89 assert result == query90 def test_payee_validation(self):91 postfix = ['x', 'not', '@']92 with pytest.raises(ValueError):93 expression.build_expr_from_postfix(postfix)94 def test_precedence(self):95 postfix = ['y', 'not', 'x', '@', 'and']96 result = expression.build_expr_from_postfix(postfix)97 query = And((PayeeQuery(RegexQuery.from_string('x')),98 Not(RegexQuery.from_string('y'))))99 assert result == query100class TestBuildExpression:101 def test_binary(self):102 postfix = 'x or y'103 result = expression.build_expression(postfix)104 query = Or((RegexQuery.from_string('y'),105 RegexQuery.from_string('x')))106 assert result == query107 postfix = 'x and y'108 result = expression.build_expression(postfix)109 query = And((RegexQuery.from_string('y'),110 RegexQuery.from_string('x')))111 assert result == query112 def test_unary(self):113 postfix = 'not x'114 result = expression.build_expression(postfix)115 query = Not(RegexQuery.from_string('x'))116 assert result == query117 def test_single(self):118 postfix = 'x'119 result = expression.build_expression(postfix)120 query = RegexQuery.from_string('x')121 assert result == query122 def test_implicit_or(self):123 postfix = 'x y'124 result = expression.build_expression(postfix)125 query = Or((RegexQuery.from_string('y'),126 RegexQuery.from_string('x')))...
coordination.py
Source:coordination.py
...17 ex.less_than(1).and_less_than(2)18 self.assertRaises(AssertionError, lambda: ex.resolve(1))19 ex.less_than(2).And_less_than(1)20 self.assertRaises(AssertionError, lambda: ex.resolve(1))21 def test_implicit_or(self):22 ex = Expectation(deferred=True, def_op=OPERATOR.OR)23 ex.equal(1).equal(0)24 ex.resolve(0)25 ex.equal(0).equal(1)26 ex.resolve(0)27 ex.equal(1).equal(2)28 self.assertRaises(AssertionError, lambda: ex.resolve(0))29 def test_explicit_or(self):30 ex = Expectation(deferred=True)31 ex.equal(1).or_equal(0)32 ex.resolve(0)33 ex.equal(0).Or_equal(1)34 ex.resolve(0)35 ex.equal(1).OR_equal(2)...
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!!