Best Python code snippet using pyshould_python
test_matcher.py
Source: test_matcher.py
...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):...
dsl.py
Source: dsl.py
...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'))...
matcher.py
Source: matcher.py
...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()
Check out the latest blogs from LambdaTest on this topic:
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
Hey LambdaTesters! We’ve got something special for you this week. ????
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!!