Best Python code snippet using tox_python
test_parse_scalars.py
Source: test_parse_scalars.py
...46 sclr = parse_scalars.ScalarType("CATEGORY",47 "PROVE",48 scalar,49 strict_type_checks=True)50 ParserError.exit_func()51 self.assertEqual(sclr.notification_emails, ["test01@mozilla.com", "test02@mozilla.com"])52 def test_invalid_email_address(self):53 SAMPLE_SCALAR_INVALID_ADDRESSES = """54description: A nice one-line description.55expires: never56record_in_processes:57 - 'main'58kind: uint59notification_emails:60 - test01@mozilla.com, test02@mozilla.com61products: ["firefox"]62bug_numbers:63 - 1234564"""65 scalar = load_scalar(SAMPLE_SCALAR_INVALID_ADDRESSES)66 parse_scalars.ScalarType("CATEGORY",67 "PROVE",68 scalar,69 strict_type_checks=True)70 self.assertRaises(SystemExit, ParserError.exit_func)71 def test_multistore_default(self):72 SAMPLE_SCALAR = """73description: A nice one-line description.74expires: never75record_in_processes:76 - 'main'77kind: uint78notification_emails:79 - test01@mozilla.com80products: ["firefox"]81bug_numbers:82 - 1234583"""84 scalar = load_scalar(SAMPLE_SCALAR)85 sclr = parse_scalars.ScalarType("CATEGORY",86 "PROVE",87 scalar,88 strict_type_checks=True)89 ParserError.exit_func()90 self.assertEqual(sclr.record_into_store, ["main"])91 def test_multistore_extended(self):92 SAMPLE_SCALAR = """93description: A nice one-line description.94expires: never95record_in_processes:96 - 'main'97kind: uint98notification_emails:99 - test01@mozilla.com100bug_numbers:101 - 12345102products: ["firefox"]103record_into_store:104 - main105 - sync106"""107 scalar = load_scalar(SAMPLE_SCALAR)108 sclr = parse_scalars.ScalarType("CATEGORY",109 "PROVE",110 scalar,111 strict_type_checks=True)112 ParserError.exit_func()113 self.assertEqual(sclr.record_into_store, ["main", "sync"])114 def test_multistore_empty(self):115 SAMPLE_SCALAR = """116description: A nice one-line description.117expires: never118record_in_processes:119 - 'main'120kind: uint121notification_emails:122 - test01@mozilla.com123bug_numbers:124 - 12345125products: ["firefox"]126record_into_store: []127"""128 scalar = load_scalar(SAMPLE_SCALAR)129 parse_scalars.ScalarType("CATEGORY",130 "PROVE",131 scalar,132 strict_type_checks=True)133 self.assertRaises(SystemExit, ParserError.exit_func)134 def test_operating_systems_default(self):135 SAMPLE_SCALAR = """136description: A nice one-line description.137expires: never138record_in_processes:139 - 'main'140kind: uint141notification_emails:142 - test01@mozilla.com143products: ["firefox"]144bug_numbers:145 - 12345146"""147 scalar = load_scalar(SAMPLE_SCALAR)148 sclr = parse_scalars.ScalarType("CATEGORY",149 "PROVE",150 scalar,151 strict_type_checks=True)152 ParserError.exit_func()153 self.assertEqual(sclr.operating_systems, ["all"])154 def test_operating_systems_custom(self):155 SAMPLE_SCALAR = """156description: A nice one-line description.157expires: never158record_in_processes:159 - 'main'160kind: uint161notification_emails:162 - test01@mozilla.com163bug_numbers:164 - 12345165products: ["firefox"]166operating_systems:167 - windows168"""169 scalar = load_scalar(SAMPLE_SCALAR)170 sclr = parse_scalars.ScalarType("CATEGORY",171 "PROVE",172 scalar,173 strict_type_checks=True)174 ParserError.exit_func()175 self.assertEqual(sclr.operating_systems, ["windows"])176 def test_operating_systems_empty(self):177 SAMPLE_SCALAR = """178description: A nice one-line description.179expires: never180record_in_processes:181 - 'main'182kind: uint183notification_emails:184 - test01@mozilla.com185bug_numbers:186 - 12345187products: ["firefox"]188operating_systems: []...
TikTok_Clicker.py
Source: TikTok_Clicker.py
...6import sys7import keyboard8910def exit_func():11 if keyboard.is_pressed('F2'):12 sys.exit()13 14def sleep_func():15 time.sleep((random.uniform(0.8, 2.2)))16 17def a(b):18 for i in range(b):19 exit_func()20 pyautogui.moveTo(683, 572)21 exit_func()22 sleep_func()23 exit_func()24 pyautogui.doubleClick()25 exit_func()26 sleep_func()27 exit_func()28 pyautogui.moveTo(1333, 559)29 exit_func()30 sleep_func()31 exit_func()32 pyautogui.click()33 exit_func()34 sleep_func()35 exit_func()36 pyautogui.moveTo(683, 572)37 exit_func()38 sleep_func()39 exit_func()40 pyautogui.doubleClick()41 exit_func()42 sleep_func()43 exit_func()44def a_2(b):45 for i in range(b):46 exit_func()47 pyautogui.moveTo(683, 572)48 exit_func()49 sleep_func()50 exit_func()51 pyautogui.doubleClick()52 exit_func()53 sleep_func()54 exit_func()55 pyautogui.moveTo(1833, 151)56 exit_func()57 sleep_func()58 exit_func()59 pyautogui.click()60 exit_func()61 sleep_func()62 exit_func()63 pyautogui.moveTo(1333, 559)64 exit_func()65 sleep_func()66 exit_func()67 pyautogui.click()68 exit_func()69 sleep_func()70 exit_func()71 pyautogui.moveTo(683, 572)72 exit_func()73 sleep_func()74 exit_func()75 pyautogui.doubleClick()76 exit_func()77 sleep_func()78 exit_func()79sg.theme('DarkGrey13') 8081author = sg.Button('Created by Maik Ãâ¸', enable_events=True, key='-LINK-', button_color=('white', 'grey'))8283layout = [[sg.Text("""8485ââââââââââââââââââââââ 86ââââââââââââââââââââââ 8788ââââââââââââ ââââ âââââââââââââ89ââââââââââââ ââââ âââââââââââââ90 """)], [sg.T("")],91 [sg.Text(':')], 92 [sg.Text('- The space bar function')],
...
callback_decorator.py
Source: callback_decorator.py
1from functools import wraps2class Context:3 '''Utility class to wrap a function with `with` such that4 enter and exit callbacks are called before and after, respectively.5 Example6 -------7 with Context(setup, cleanup):8 something()9 See also10 --------11 decorate_callback12 '''13 def __init__(self, enter_callback, exit_callback):14 '''15 '''16 self.enter_callback = enter_callback17 self.exit_callback = exit_callback18 def __enter__(self):19 '''20 '''21 self.enter_callback()22 def __exit__(self, *args, **kwargs):23 '''24 '''25 self.exit_callback()26def decorate_callback(func, enter_func, exit_func):27 '''runs runs enter_func before the call to func and exit_func after.28 Parameters29 ----------30 func : function31 function to be wrapped.32 enter_func : function33 function to be called before func.34 exit_func : function35 function to be called after func.36 Returns37 -------38 wrapped_func : function39 func decorated with Context(enter_func, exit_func).40 '''41 @wraps(func)42 def wrapped(*args, **kwargs):43 with Context(enter_func, exit_func):44 return func(*args, **kwargs)...
Check out the latest blogs from LambdaTest on this topic:
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
Mobile devices and mobile applications – both are booming in the world today. The idea of having the power of a computer in your pocket is revolutionary. As per Statista, mobile accounts for more than half of the web traffic worldwide. Mobile devices (excluding tablets) contributed to 54.4 percent of global website traffic in the fourth quarter of 2021, increasing consistently over the past couple of years.
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.
JUnit is one of the most popular unit testing frameworks in the Java ecosystem. The JUnit 5 version (also known as Jupiter) contains many exciting innovations, including support for new features in Java 8 and above. However, many developers still prefer to use the JUnit 4 framework since certain features like parallel execution with JUnit 5 are still in the experimental phase.
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!!