Best Python code snippet using localstack_python
test_match.py
Source:test_match.py
...17#18# * (star) can substitute for exactly one word.19# (hash) can substitute for zero or more words.20class TestMatch(unittest.TestCase):21 def assert_match(self, routing_key, message_type):22 self.assertEqual(match([routing_key], message_type), True)23 def assert_no_match(self, routing_key, message_type):24 self.assertEqual(match([routing_key], message_type), False)25 def test_direct_match(self):26 self.assert_match('foo', 'foo')27 self.assert_no_match('foo', 'bar')28 self.assert_no_match('foo', 'foo.bar')29 self.assert_no_match('foo', 'bar.foo')30 self.assert_no_match('foo', 'foo.foo')31 def test_hash(self):32 self.assert_match('#', 'foo')33 def test_hash_then_word(self):34 self.assert_match('#.foo', 'foo.foo')35 self.assert_no_match('#.foo', 'foo.barbar')36 self.assert_no_match('#.foo', 'foo.baz')37 def test_hash_then_star(self):38 self.assert_match('#.*', 'foo.bar')39 self.assert_match('#.*', 'foo.bar.baz')40 self.assert_match('#.*', 'foo.bar.baz.qux')41 self.assert_match('#.*', 'foo.bar.baz.qux.quux')42 self.assert_match('#.*', 'foo.bar.baz.qux.quux.corge')43 self.assert_match('#.*', 'foo.bar.baz.qux.quux.corge.grault')44 self.assert_match('#.*', 'foo.bar.baz.qux.quux.corge.garply')45 self.assert_match('#.*', 'foo.bar.baz.qux.quux.corge.garply.waldo')46 self.assert_match(47 '#.*', 'foo.bar.baz.qux.quux.corge.garply.waldo.fred')48 self.assert_match(49 '#.*', 'foo.bar.baz.qux.quux.corge.garply.waldo.fred.plugh')...
test_lldbgdbserverutils.py
Source:test_lldbgdbserverutils.py
...3from lldbgdbserverutils import *4class TestLldbGdbServerUtils(unittest2.TestCase):5 def test_entry_exact_payload_match(self):6 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")7 entry.assert_match(self, "$OK#9a")8 def test_entry_exact_payload_match_ignores_checksum(self):9 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")10 entry.assert_match(self, "$OK#00")11 def test_entry_creates_context(self):12 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")13 context = entry.assert_match(self, "$OK#9a")14 self.assertIsNotNone(context)15 def test_entry_regex_matches(self):16 entry = GdbRemoteEntry(17 is_send_to_remote=False,18 regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"),19 capture={20 1: "thread_id"})21 context = entry.assert_match(self, "$QC980#00")22 def test_entry_regex_saves_match(self):23 entry = GdbRemoteEntry(24 is_send_to_remote=False,25 regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"),26 capture={27 1: "thread_id"})28 context = entry.assert_match(self, "$QC980#00")29 self.assertEqual(context["thread_id"], "980")30 def test_entry_regex_expect_captures_success(self):31 context = {"thread_id": "980"}32 entry = GdbRemoteEntry(33 is_send_to_remote=False,34 regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"),35 expect_captures={36 2: "thread_id"})37 entry.assert_match(self, "$T11thread:980;", context=context)38 def test_entry_regex_expect_captures_raises_on_fail(self):39 context = {"thread_id": "980"}40 entry = GdbRemoteEntry(41 is_send_to_remote=False,42 regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"),43 expect_captures={44 2: "thread_id"})45 try:46 entry.assert_match(self, "$T11thread:970;", context=context)47 self.fail()48 except AssertionError:49 # okay...
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!!