Best Python code snippet using assertpy_python
demo04.py
Source: demo04.py
...13# æ§åè½14def say_hello():15 # print_func_name(say_hello)16 print("hello")17def say_goodbye():18 # print_func_name(say_goodbye)19 print("goodbye")20# say_hello = æ§åè½ + æ°åè½21say_hello = print_func_name(say_hello)22# æ¦æª23say_goodbye = print_func_name(say_goodbye)24say_hello()25say_goodbye()26"""27"""28def print_func_name(func):29 def wrapper():30 # æ§è¡æ°åè½31 print("被è°ç¨çå½æ°æ¯ï¼", func.__name__)32 # æ§è¡æ§åè½33 func()34 return wrapper35 36# æ§åè½37@print_func_name # say_hello = print_func_name(say_hello)38def say_hello():39 print("hello")40@print_func_name # say_goodbye = print_func_name(say_goodbye)41def say_goodbye():42 print("goodbye")43say_hello()44say_goodbye()45"""46""" å
é¨å½æ°å¢å è¿åå¼47def print_func_name(func):48 def wrapper():49 # æ§è¡æ°åè½50 print("被è°ç¨çå½æ°æ¯ï¼", func.__name__)51 # æ§è¡æ§åè½52 return func()53 return wrapper54# æ§åè½55@print_func_name # say_hello = print_func_name(say_hello)56def say_hello():57 print("hello")58@print_func_name # say_goodbye = print_func_name(say_goodbye)59def say_goodbye():60 print("goodbye")61 return 10062print(say_hello())63print(say_goodbye())64"""65def print_func_name(func):66 def wrapper(*args,**kwargs):# å ("qtx",)67 # æ§è¡æ°åè½68 print("被è°ç¨çå½æ°æ¯ï¼", func.__name__)69 # æ§è¡æ§åè½70 return func(*args,**kwargs)# æ71 return wrapper72# æ§åè½73@print_func_name # say_hello = print_func_name(say_hello)74def say_hello(name1,name2):# "qtx"75 print(name1,name2,"hello")76@print_func_name # say_goodbye = print_func_name(say_goodbye)77def say_goodbye():78 print("goodbye")79 return 10080print(say_hello("qtx",name2 = "lzmly"))81print(say_goodbye())...
State.py
Source: State.py
2 3 def say_hello(self):4 pass5 6 def say_goodbye(self):7 pass8class HappyState(EmotionalState):9 def say_goodbye(self):10 return "Bye :)"11 def say_hello(self):12 return "Hello :)"13 14class SadState(EmotionalState):15 def say_goodbye(self):16 return "Bye :("17 def say_hello(self):18 return "Hello :("19 20class Person(EmotionalState):21 def __init__(self, state):22 self.state = state23 def set_state(self, state):24 self.state = state25 def say_goodbye(self):26 return self.state.say_goodbye()27 def say_hello(self):28 return self.state.say_hello()29 30 31person = Person(HappyState())32print("Hello in happy : " + person.say_hello())33print("Goodbye in happy : " + person.say_goodbye())34person.set_state(SadState())35print("Hello in sad : " + person.say_hello())36print("Goodbye in sad : " + person.say_goodbye()) 37 ...
hello_world_dag.py
Source: hello_world_dag.py
1from airflow import DAG2from datetime import datetime, timedelta3from airflow.utils.dates import days_ago4from airflow.operators.bash_operator import BashOperator5default_args = {6 'owner': 'airflow',7 'depends_on_past': False,8 'email': ['test@yourdomain.com'],9 'email_on_failure': False,10 'email_on_retry': False11}12DAG_ID = "hello_world_scheduled_dag"13dag = DAG(14 dag_id=DAG_ID,15 default_args=default_args,16 description='Scheduled Apache Airflow DAG',17 schedule_interval='* 1 * * *',18 start_date=days_ago(1),19 tags=['aws','demo'],20)21say_hello = BashOperator(22 task_id='say_hello',23 bash_command="echo hello" ,24 dag=dag25 )26say_goodbye = BashOperator(27 task_id='say_goodbye',28 bash_command="echo goodbye",29 dag=dag30 )...
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.
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
If you pay close attention, you’ll notice that toggle switches are all around us because lots of things have two simple states: either ON or OFF (in binary 1 or 0).
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!!