Best Python code snippet using localstack_python
test_settings.py
Source: test_settings.py
...36 os.environ['SETTING__PYMAID__FLOAT'] = 'float::5.13543512414351235'37 os.environ['SETTING__PYMAID__BOOL'] = 'bool::False'38 os.environ['SETTING__PYMAID__DICT'] = 'dict::{"age": 18}'39 os.environ['SETTING__PYMAID__LIST'] = 'list::[1, 2, 3]'40 settings.load_from_environment(prefix='SETTING__')41 assert settings.get('NOT_EXIST', ns='pymaid') == 'noway'42 assert settings.get('NOT_EXIST', default='what') == b'noway'43 assert settings.get('MAX_TASKS', ns='pymaid') == 12844 assert abs(settings.get('FLOAT', ns='pymaid') - 5.13543512414351235) < 1e-6 # noqa45 assert settings.get('BOOL', ns='pymaid') is False46 assert settings.get('DICT', ns='pymaid') == {'age': 18}47 assert settings.get('LIST', ns='pymaid') == [1, 2, 3]48def test_load_env_bad_cases():49 # wrong prefix50 settings.namespaces.clear()51 os.environ['SETTING__PYMAID__LIST'] = 'list::[1, 2, 3]'52 with pytest.raises(ValueError):53 settings.load_from_environment(prefix='SETTING_')54 assert settings.get('LIST', ns='pymaid') is None55 assert not settings.namespaces56 os.environ.clear()57 with pytest.raises(ValueError):58 settings.load_from_environment(prefix='SETTING___')59 assert settings.get('LIST', ns='pymaid') is None60 assert not settings.namespaces61 # wrong namespace62 os.environ['SETTING___PYMAID__LIST'] = 'list::[1, 2, 3]'63 settings.load_from_environment(prefix='SETTING__')64 assert settings.get('LIST', ns='pymaid') is None65 assert not settings.namespaces66 # wrong key67 os.environ['SETTING__PYMAID___LIST'] = 'list::[1, 2, 3]'68 settings.load_from_environment(prefix='SETTING__')69 assert settings.get('LIST', ns='pymaid') is None70 assert not settings.namespaces71 # wrong value format72 os.environ['SETTING__PYMAID__LIST'] = '[1, 2, 3]'73 with pytest.raises(ValueError):74 settings.load_from_environment(prefix='SETTING__')75 assert settings.get('LIST', ns='pymaid') is None76 assert not settings.namespaces77 os.environ['SETTING__PYMAID__LIST'] = 'list:[1, 2, 3]'78 with pytest.raises(ValueError):79 settings.load_from_environment(prefix='SETTING__')80 assert settings.get('LIST', ns='pymaid') is None81 assert not settings.namespaces82 # wrong value type83 os.environ['SETTING__PYMAID__LIST'] = 'what_type::[1, 2, 3]'84 with pytest.raises(ValueError):85 settings.load_from_environment(prefix='SETTING__')86 assert settings.get('LIST', ns='pymaid') is None87 assert not settings.namespaces88 # wrong type::value89 os.environ['SETTING__PYMAID__LIST'] = 'int::[1, 2, 3]'90 with pytest.raises(ValueError):91 settings.load_from_environment(prefix='SETTING__')92 assert settings.get('LIST', ns='pymaid') is None93 assert not settings.namespaces94def test_dot_get():95 assert settings.pymaid.DEBUG == defaults.DEBUG96 # not exists namespace97 with pytest.raises(AttributeError):98 settings.what99 # not exists key100 with pytest.raises(AttributeError):101 settings.pymaid.what102def test_dot_set():103 assert settings.pymaid.MAX_TASKS == defaults.MAX_TASKS104 settings.pymaid.MAX_TASKS += 1105 assert settings.pymaid.MAX_TASKS == defaults.MAX_TASKS + 1...
application_config.py
Source: application_config.py
...18 try:19 config.update(yaml.load(stream, Loader=yaml.Loader))20 except yaml.YAMLError as e:21 raise Exception("Error parsing config file", e)22def load_from_environment():23 for property in properties:24 if property in os.environ:25 config[property] = os.environ[property]26def load_configs():27 load_defaults()28 load_config_file()29 load_from_environment()30def __get_next_config(path: list, tree_config: dict):31 if path is None or len(path) == 0:32 return None33 current_config_key = path[0]34 if current_config_key not in tree_config:35 return None36 current_config_value = tree_config[current_config_key]37 next_path = path.copy()38 next_path.remove(current_config_key)39 if len(next_path) == 0:40 return current_config_value41 return __get_next_config(next_path, current_config_value)42def get_config(path: list) -> dict:43 return __get_next_config(path, config)...
application.py
Source: application.py
...3from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine4from falert.backend.common.configuration import Configuration, load_from_environment5class BaseApplication:6 def __init__(self):7 self.__configuration = load_from_environment()8 self.__engine = create_async_engine(9 self.__configuration.database_url,10 echo=self.__configuration.database_echo,11 )12 self.__logger = getLogger(None)13 basicConfig()14 self.__logger.setLevel(DEBUG)15 @property16 def _configuration(self) -> Configuration:17 return self.__configuration18 @property19 def _engine(self) -> AsyncEngine:20 return self.__engine21 @property...
Check out the latest blogs from LambdaTest on this topic:
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
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!!