Best Python code snippet using yandex-tank
plugin.py
Source:plugin.py
...65 if self.stats_reader is None:66 self.stats_reader = BfgStatsReader(self.bfg.instance_counter, self.stepper_wrapper.steps)67 return self.stats_reader68 @property69 def bfg(self):70 if self._bfg is None:71 BFG = BFGGreen if self.get_option("worker_type", "") == "green" else BFGMultiprocessing72 self._bfg = BFG(73 gun=self.gun,74 instances=self.stepper_wrapper.instances,75 stpd_filename=self.stepper_wrapper.stpd,76 cached_stpd=self.get_option("cached_stpd"),77 green_threads_per_instance=int(self.get_option('green_threads_per_instance', 1000)),78 )79 return self._bfg80 def prepare_test(self):81 pip_deps = self.get_option("pip", "").splitlines()82 self.log.info("Installing with PIP: %s", pip_deps)83 if pip_deps:...
calc.py
Source:calc.py
1# Calculator2# # Info on Tkinter3# https://realpython.com/python-gui-tkinter/45# Import only Tk (interface), Widgets - Entry (text input) and Button6from tkinter import Tk, Entry, Button 78gui = Tk()9gui.configure(background="light green")10gui.title("Calculator")11gui.geometry(f"270x300+{gui.winfo_screenwidth()-270}+0")1213# Interface Variables14font = "Calibri 16"15c = 3 # number of columns16r = 7 # number of rows17bbg = "white"18bfg = "black"1920# Build Graphical User Interface2122# Text Input23screen = Entry(gui, fg="red", bg="black", bd=5, font=font)24screen.place(relw=c/c, relh=1/r, relx=0, rely=0)2526def btn_click(num):27 screen_contents = screen.get()28 print(num)29 screen.insert(len(screen_contents), str(num))30 31def clear():32 print('Clear')33 screen_contents = screen.get()34 screen.delete(0, len(screen_contents))35 36def calculate():37 screen_contents = screen.get()38 result = str(eval(screen_contents))39 clear()40 screen.insert(len(screen_contents), result)4142# Buttons4344# Numbers45Button(gui, text="1", fg=bfg, bg=bbg, font=font, command=lambda num=1 : btn_click(num)).place(relw=1/c, relh=1/r, relx=0, rely=1/r)46Button(gui, text="2", fg=bfg, bg=bbg, font=font, command=lambda num=2 : btn_click(num)).place(relw=1/c, relh=1/r, relx=1/c, rely=1/r)47Button(gui, text="3", fg=bfg, bg=bbg, font=font, command=lambda num=3 : btn_click(num)).place(relw=1/c, relh=1/r, relx=2/c, rely=1/r)48Button(gui, text="4", fg=bfg, bg=bbg, font=font, command=lambda num=4 : btn_click(num)).place(relw=1/c, relh=1/r, relx=0, rely=2/r)49Button(gui, text="5", fg=bfg, bg=bbg, font=font, command=lambda num=5 : btn_click(num)).place(relw=1/c, relh=1/r, relx=1/c, rely=2/r)50Button(gui, text="6", fg=bfg, bg=bbg, font=font, command=lambda num=6 : btn_click(num)).place(relw=1/c, relh=1/r, relx=2/c, rely=2/r)51Button(gui, text="7", fg=bfg, bg=bbg, font=font, command=lambda num=7 : btn_click(num)).place(relw=1/c, relh=1/r, relx=0, rely=3/r)52Button(gui, text="8", fg=bfg, bg=bbg, font=font, command=lambda num=8 : btn_click(num)).place(relw=1/c, relh=1/r, relx=1/c, rely=3/r)53Button(gui, text="9", fg=bfg, bg=bbg, font=font, command=lambda num=9 : btn_click(num)).place(relw=1/c, relh=1/r, relx=2/c, rely=3/r)5455Button(gui, text="+", fg=bfg, bg=bbg, font=font, command=lambda num="+" : btn_click(num)).place(relw=1/c, relh=1/r, relx=0, rely=4/r)56Button(gui, text="0", fg=bfg, bg=bbg, font=font, command=lambda num=0 : btn_click(num)).place(relw=1/c, relh=1/r, relx=1/c, rely=4/r)57Button(gui, text="-", fg=bfg, bg=bbg, font=font, command=lambda num="-" : btn_click(num)).place(relw=1/c, relh=1/r, relx=2/c, rely=4/r)5859Button(gui, text="*", fg=bfg, bg=bbg, font=font, command=lambda num="*" : btn_click(num)).place(relw=1/c, relh=1/r, relx=0, rely=5/r)60Button(gui, text=".", fg=bfg, bg=bbg, font=font, command=lambda num="." : btn_click(num)).place(relw=1/c, relh=1/r, relx=1/c, rely=5/r)61Button(gui, text="/", fg=bfg, bg=bbg, font=font, command=lambda num="/" : btn_click(num)).place(relw=1/c, relh=1/r, relx=2/c, rely=5/r)6263Button(gui, text="C", fg="white", bg="red", font=font, command=clear).place(relw=1/c, relh=1/r, relx=0, rely=6/r)64Button(gui, text="=", fg="white", bg="blue", font=font, command=calculate).place(relw=2/c, relh=1/r, relx=1/c, rely=6/r)6566# for i in range(1, 4):67# Button(gui, text="1", fg="black", bg="white", font=font).place(relw=1/c, relh=1/r, relx=i-1/c, rely=1/r)686970# Interface functions717273# Set everything up74gui.mainloop()7576asd = "asd"77
...
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!!