How to use test_empty_matcher method in pyshould

Best Python code snippet using pyshould_python

test_matcher.py

Source:test_matcher.py Github

copy

Full Screen

...115 bindings = OrderedBindings(bindings)116 with self.assertRaises(matcher.MatchError):117 matcher.merge_bindings(bindings, bindings)118class AccumulatingMatcherTest(absltest.TestCase):119 def test_empty_matcher(self):120 class TestMatcher(matcher.Matcher):121 @matcher.accumulating_matcher122 def _match(self, context, candidate):123 return124 yield # pylint: disable=unreachable125 self.assertIsNotNone(TestMatcher().match(_FAKE_CONTEXT, 0))126 def test_submatcher_extraction(self):127 """Tests that the return values of submatchers are sent to the generator."""128 class ValueReturningMatcher(matcher.Matcher):129 def _match(self, context, candidate):130 del candidate # unused131 return matcher.MatchInfo(132 matcher.create_match(context.parsed_file, 'hello world'), {})133 class TestMatcher(matcher.Matcher):...

Full Screen

Full Screen

dsl.py

Source:dsl.py Github

copy

Full Screen

...115 def test_callback_matcher(self):116 1 | should.pass_callback(lambda x: x == 1)117 def test_callback_matcher_nested_expectation(self):118 1 | should.pass_callback(lambda x: x | should.eq(1))119 def test_empty_matcher(self):120 [] | should.be_empty121 '' | should.be_empty122 {} | should.be_empty123 ['foo'] | should_not.be_empty124 'foo' | should_not.be_empty125 {'foo': 'foo'} | should_not.be_empty126 def test_matcher_composition(self):127 d = {'foo': 'bar'}128 d | should.have_value(should.eq('bar'))129 d | should.have_entry('foo', should.eq('baz').or_eq('bar'))130 d | should.have_key('foo').and_have_value(should.eq('bar'))131 self.assertRaises(132 AssertionError,133 lambda: d | should.have_entry('foo', should.eq('baz'))...

Full Screen

Full Screen

matcher.py

Source:matcher.py Github

copy

Full Screen

...11 self.sim.simulate(10, 13579)12 13 def test_matcher(self):14 """Test various matcher subclasses"""15 def test_empty_matcher(MatcherSub):16 """Test empty Matcher returns valid empty results"""17 ## Test that an empty set returns valid, emtpy results18 matcher_sub = MatcherSub(set([]))19 unmatched = matcher_sub.get_unmatched()20 best_matches = matcher_sub.get_best_matches()21 self.assertEqual(unmatched, set([]));22 self.assertEqual(best_matches, set([]));23 def test_matcher_matches(MatcherSub, expected_matches, expected_unmatches):24 """Spin up Matcher subclass and confirm expected results"""25 users = self.sim.get_users()26 self.assertEqual(len(users),10, "Sanity check simulator user count")27 matcher_sub = MatcherSub(users,seed=1234)28 best_matches = set([(tup[0].user_id, tup[1].user_id) for tup in matcher_sub.get_best_matches() ])29 unmatched = set([user.user_id for user in matcher_sub.get_unmatched()])30 print best_matches31 print unmatched32 for match in expected_matches:33 self.assertIn(match, best_matches, "Expected match not found - perhaps the algo or simulator changed?")34 for unmatch in expected_unmatches:35 self.assertIn(unmatch, unmatched, "Expected unmatched not found - perhaps the algo or simulator changed?")36 ## Test empty matcher return valid results37 for MatcherSub in self.all_matchers:38 test_empty_matcher(MatcherSub)39 ## For each Matcher subclass, work out what the answers should be40 ## given the simulator's users, and record the answers here41 geog_matched = [(7736498, 2837615), (5072324, 795755), (4454245, 3882723)]42 geog_unmatched = [1510961, 8148259, 6505708, 2432669]43 ## Feed the expected results into 3-tuples below to be tested44 ## (MatcherSubclass , expected_match_results, expected_unmatched_results)45 test_cases = [46 (GeogMatcher, geog_matched,geog_unmatched)47 ]48 ## Test full matchers return correct results49 for match_case in test_cases:50 test_matcher_matches(*match_case)51if __name__ == '__main__':52 unittest.main()

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 pyshould 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