Best Python code snippet using robotframework-appiumlibrary_python
test_context.py
Source: test_context.py
...48 self.assertEqual(ctx.session_id, "abcd")49 @patch("samcli.cli.context.click")50 def test_must_find_context(self, click_mock):51 ctx = Context()52 result = ctx.get_current_context()53 self.assertEqual(click_mock.get_current_context.return_value.find_object.return_value, result)54 click_mock.get_current_context.return_value.find_object.assert_called_once_with(Context)55 @patch("samcli.cli.context.click")56 def test_create_new_context_if_not_found(self, click_mock):57 # Context can't be found58 click_mock.get_current_context.return_value.find_object.return_value = None59 ctx = Context()60 result = ctx.get_current_context()61 self.assertEqual(click_mock.get_current_context.return_value.ensure_object.return_value, result)62 click_mock.get_current_context.return_value.ensure_object.assert_called_once_with(Context)63 @patch("samcli.cli.context.click")64 def test_get_current_context_from_outside_of_click(self, click_mock):65 click_mock.get_current_context.return_value = None66 ctx = Context()67 # Context can't be found...
user_service.py
Source: user_service.py
...5class UserService:6 @staticmethod7 async def find(user_id: str):8 if user_id:9 ctx = get_current_context()10 try:11 return await ctx.db.get(User, User.user_id == user_id)12 except:13 return None14 @staticmethod15 async def find_by_email(email: str):16 if email:17 ctx = get_current_context()18 try:19 return await ctx.db.get(User, User.email == email)20 except:21 return None22 @staticmethod23 def verify_password(user: User, password: str):24 try:25 return verify_hash(user.password, password)26 except:27 return False28 @staticmethod29 async def set_password(user: User, new_password: str):30 ctx = get_current_context()31 user.password = hash_password(new_password)32 await ctx.db.update(user)33 @staticmethod34 async def create_new_tokens(user: User):35 ctx = get_current_context()36 new_token_key = generate_unique_id()37 user.token_key = new_token_key38 await ctx.db.update(user)39 secret = create_secret(user)40 auth_token = create_auth_token(user, secret)41 refresh_token = create_refresh_token(user, secret)...
test_context_mem_safety.py
Source: test_context_mem_safety.py
2import pytest3import imgui4@pytest.fixture()5def no_context():6 ctx = imgui.get_current_context()7 if ctx is not None:8 imgui.destroy_context(ctx)9def test_get_current_context_no_context(no_context):10 assert imgui.get_current_context() is None11def test_create_context_no_context(no_context):12 ctx = imgui.create_context()13 assert ctx is not None14 assert imgui.get_current_context() is not None15def test_create_context_ctx_object_identity(no_context):16 ctx = imgui.create_context()17 assert ctx is not None18 assert ctx == imgui.get_current_context()19def test_destroy_empty_context(no_context):20 with pytest.raises(RuntimeError):21 imgui.destroy_context()22def test_destroy_destroyed_context(no_context):23 ctx = imgui.create_context()24 assert ctx is not None25 imgui.destroy_context(ctx)26 with pytest.raises(RuntimeError):27 imgui.destroy_context(ctx)28def test_set_current_context_destroyed(no_context):29 ctx = imgui.create_context()30 assert ctx is not None31 imgui.destroy_context(ctx)32 imgui.set_current_context(ctx)...
Check out the latest blogs from LambdaTest on this topic:
Traditional software testers must step up if they want to remain relevant in the Agile environment. Agile will most probably continue to be the leading form of the software development process in the coming years.
Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
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.
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.
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!!