How to assert if Python enum contains specific string key or value

15 Uncategorized Leave a Comment
To assert if Python enum contains specific string key or value, we need helper function. class BaseEnum(Enum): @classmethod def has_name(cls, name): return name in cls._member_names_ @classmethod def has_value(cls, value): return value in cls._value2member_map_ class StatusEnum(str, BaseEnum): PUBLISHED = 1 PEN…

How to use Gmail to send email in Python

45 Uncategorized Leave a Comment
1 Add "App password" Go to Google account "Security", navigate to "Signing in to Google" and click "App passwords". Then select a type, here we use "Mail" and custom the device name. Type device name as "airflow", or you can choose any other name. Then…