Best Python code snippet using autotest_python
test_logger.py
Source:test_logger.py
...60 logs = LogConfig.config61 logs.logger_set = True62 logs.set_level("DEBUG")63def test_set_stderr_level():64 stderr_level = logger.get_stderr_level()65 assert stderr_level == 35, "Default stderr copying level is 35, found " + str(stderr_level)66 logger.set_stderr_level("DEBUG")67 stderr_level = logger.get_stderr_level()68 assert stderr_level == 10, "Log level should be 10. Found: " + str(stderr_level)69 logger.set_stderr_level("INFO")70 stderr_level = logger.get_stderr_level()71 assert stderr_level == 20, "Log level should be 20. Found: " + str(stderr_level)72 logger.set_stderr_level("WARNING")73 stderr_level = logger.get_stderr_level()74 assert stderr_level == 30, "Log level should be 30. Found: " + str(stderr_level)75 logger.set_stderr_level("MANAGER_WARNING")76 stderr_level = logger.get_stderr_level()77 assert stderr_level == 35, "Log level should be 35. Found: " + str(stderr_level)78 logger.set_stderr_level("ERROR")79 stderr_level = logger.get_stderr_level()80 assert stderr_level == 40, "Log level should be 40. Found: " + str(stderr_level)81 logger.set_level("ERROR")82 logger_test = logging.getLogger("libensemble")83 logger_test.manager_warning("This test message should not log")84# Need setup/teardown here to kill loggers if running file without pytest85# Issue: cannot destroy loggers and they are set up in other unit tests.86# Partial solution: either rename the file so it is the first unit test, or87# move this unit test to its own directory.88if __name__ == "__main__":89 test_set_log_level()90 # test_change_log_level()91 test_set_filename()...
__init__.py
Source:__init__.py
1# Copyright (c) 2020 6WIND S.A.2# SPDX-License-Identifier: BSD-3-Clause3from .change import (4 Change,5 ChangeCreated,6 ChangeDeleted,7 ChangeModified,8 ChangeMoved,9 update_config_cache,10)11from .connection import SysrepoConnection12from .errors import (13 SysrepoCallbackFailedError,14 SysrepoCallbackShelveError,15 SysrepoError,16 SysrepoExistsError,17 SysrepoInternalError,18 SysrepoInvalArgError,19 SysrepoLockedError,20 SysrepoLyError,21 SysrepoNomemError,22 SysrepoNotFoundError,23 SysrepoOperationFailedError,24 SysrepoSysError,25 SysrepoTimeOutError,26 SysrepoUnauthorizedError,27 SysrepoUnsupportedError,28 SysrepoValidationFailedError,29)30from .util import configure_logging, get_stderr_level, get_syslog_level31from .value import (32 AnyData,33 AnyXML,34 Binary,35 Bits,36 Bool,37 Container,38 ContainerPresence,39 Decimal64,40 Enum,41 IdentityRef,42 InstanceId,43 Int8,44 Int16,45 Int32,46 Int64,47 LeafEmpty,48 List,49 String,50 UInt8,51 UInt16,52 UInt32,53 UInt64,54 Value,55)56__all__ = [57 "SysrepoConnection",58 "Change",59 "ChangeCreated",60 "ChangeDeleted",61 "ChangeModified",62 "ChangeMoved",63 "SysrepoError",64 "SysrepoCallbackFailedError",65 "SysrepoCallbackShelveError",66 "SysrepoExistsError",67 "SysrepoInternalError",68 "SysrepoInvalArgError",69 "SysrepoLockedError",70 "SysrepoLyError",71 "SysrepoNomemError",72 "SysrepoNotFoundError",73 "SysrepoOperationFailedError",74 "SysrepoSysError",75 "SysrepoTimeOutError",76 "SysrepoUnauthorizedError",77 "SysrepoUnsupportedError",78 "SysrepoValidationFailedError",79 "AnyData",80 "AnyXML",81 "Binary",82 "Bits",83 "Bool",84 "Container",85 "ContainerPresence",86 "Decimal64",87 "Enum",88 "IdentityRef",89 "InstanceId",90 "Int16",91 "Int32",92 "Int64",93 "Int8",94 "LeafEmpty",95 "List",96 "String",97 "UInt16",98 "UInt32",99 "UInt64",100 "UInt8",101 "Value",102 "update_config_cache",103 "configure_logging",104 "get_syslog_level",105 "get_stderr_level",...
debug.py
Source:debug.py
...11def debug_iter(iterator: Iterable[T],12 *args,13 display_current: Optional[str] = None,14 position: int = None, **kwargs) -> Iterable[T]:15 if logutils.get_stderr_level() not in ["TRACE", "DEBUG"]:16 yield from iterator17 return18 print(CF.MAGENTA, end='\r')19 kwargs.pop("dynamic_ncols", None)20 if display_current is not None:21 with tqdm.tqdm(iterator, *args, **kwargs, dynamic_ncols=True, position=position) as t:22 for result in t:23 t.set_postfix({display_current: result})24 yield result25 t.set_postfix({})26 else:27 yield from tqdm.tqdm(iterator, *args, **kwargs, dynamic_ncols=True, position=position)28 if position is None or position == 0:29 print(CS.RESET_ALL, end='\r')
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!!