Best Python code snippet using testcontainers-python_python
test_pipeline.py
Source: test_pipeline.py
...16from zaqar.tests import base17class FirstClass(object):18 def with_args(self, name):19 return name20 def with_kwargs(self, lastname='yo'):21 return lastname22 def with_args_kwargs(self, name, lastname='yo'):23 return '{0} {1}'.format(name, lastname)24 def no_args(self):25 return True26 def does_nothing(self):27 return None28 def calls_the_latest(self):29 return None30class SecondClass(object):31 def does_nothing(self):32 return None33 def calls_the_latest(self):34 return True35 def _raise_rterror(self):36 raise RuntimeError("It shouldn't get here!")37 # NOTE(flaper87): This methods will be used to test38 # that the pipeline stops at the first class returning39 # something.40 with_args = with_kwargs = no_args = _raise_rterror41class TestPipeLine(base.TestBase):42 def setUp(self):43 super(TestPipeLine, self).setUp()44 self.pipeline = pipeline.Pipeline([FirstClass(),45 SecondClass()])46 def test_attribute_error(self):47 consumer = self.pipeline.does_not_exist48 self.assertRaises(AttributeError, consumer)49 def test_with_args(self):50 name = 'James'51 self.assertEqual(name, self.pipeline.with_args(name))52 def test_with_kwargs(self):53 lastname = 'Bond'54 self.assertEqual(lastname, self.pipeline.with_kwargs(lastname))55 self.assertEqual(lastname,56 self.pipeline.with_kwargs(lastname=lastname))57 def test_with_args_kwargs(self):58 fullname = 'James Bond'59 name, lastname = fullname.split()60 result = self.pipeline.with_args_kwargs(name, lastname=lastname)61 self.assertEqual(fullname, result)62 def test_does_nothing(self):63 self.assertIsNone(self.pipeline.does_nothing())64 def test_calls_the_latest(self):65 self.assertTrue(self.pipeline.calls_the_latest())66 def test_pipeline_context_manager(self):67 ctxt = self.pipeline.consumer_for('does_nothing')68 with ctxt as consumer:...
test_validation.py
Source: test_validation.py
...14@pytest.fixture()15def with_args():16 return lambda arg1, arg2: (arg1, arg2)17@pytest.fixture()18def with_kwargs():19 return lambda arg1='val1', arg2=10: (arg1, arg2)20def test_should_fail_if_schema_invalid(with_args):21 with pytest.raises(SchemaError):22 validated({'properties': {'arg1': {'type': 'int'}}})(with_args)23def test_should_fail_if_no_schema(with_args):24 with pytest.raises(AttributeError):25 validated(None)(with_args)26def test_should_validate_if_args_ok(with_args):27 function = validated(SCHEMA)(with_args)28 assert function('a', 1)29def test_should_fail_if_args_not_ok(with_args):30 function = validated(SCHEMA)(with_args)31 with pytest.raises(ValidationError):32 function(1, 'a')...
quak.py
Source: quak.py
...5 return print(a)6myDict1 = {'b': 2, 'a': 1, 'c': 3}7no_kwargs(myDict1)8# With **kwargs9def with_kwargs(a, b, c, **kwargs):10 """ a, b, c representing the keys inside the Dictionary """11 return print(a, b, c, **kwargs)12myDict2 = {'b': 2, 'a': 1, 'c': 3}13with_kwargs(**myDict2)14# Error with **kwargs15# def with_kwargs(a, b, c, **kwargs):16# """ a, b, c representing the keys inside the Dictionary """17# return print(a, b, c, **kwargs) # error, invalid keyword: d is missing from the Dictionary18#19#20# myDict3 = {'b': 2, 'a': 1, 'c': 3, 'd': 4}21# with_kwargs(**myDict3)22# prevent error with **kwargs23def with_kwargs(a, b, c, d, **kwargs): # same keys needed as the Dictionary provides24 """ a, b, c representing the keys inside the Dictionary """25 return print(d, a, c) # but return, whatever you want26myDict3 = {'b': 2, 'a': 1, 'c': 3, 'd': 4}...
Check out the latest blogs from LambdaTest on this topic:
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
In today’s data-driven world, the ability to access and analyze large amounts of data can give researchers, businesses & organizations a competitive edge. One of the most important & free sources of this data is the Internet, which can be accessed and mined through web scraping.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
Even though several frameworks are available in the market for automation testing, Selenium is one of the most renowned open-source frameworks used by experts due to its numerous features and benefits.
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!!