Best Python code snippet using autotest_python
configurations.py
Source: configurations.py
...39 incfiles = [incfiles]40 for predfile in incfiles:41 confpath = os.path.join(self.tailseeker_dir, 'conf', predfile)42 predconf = self.load_config(open(confpath))43 confdict = self.merge_configs(confdict, predconf)44 confdict = self.merge_configs(confdict, usersettings)45 return confdict46 else:47 return usersettings48 def merge_configs(self, conf1, conf2):49 merged = {}50 for conf1only in set(conf1) - set(conf2):51 merged[conf1only] = conf1[conf1only]52 for conf2only in set(conf2) - set(conf1):53 merged[conf2only] = conf2[conf2only]54 for shared in set(conf1) & set(conf2):55 if isinstance(conf1[shared], dict) != isinstance(conf1[shared], dict):56 raise ValueError('Layout is different between overriding configurations.')57 if isinstance(conf1[shared], dict):58 merged[shared] = self.merge_configs(conf1[shared], conf2[shared])59 else:60 merged[shared] = conf2[shared] # conf2 is overriding conf1.61 return merged62 def __getitem__(self, name):63 return self.confdata[name]64 def __contains__(self, name):65 return name in self.confdata66 def get(self, name, default=None):67 return self.confdata.get(name, default)68 def expand_sample_settings(self, node):69 predefined = {70 '_all': self.all_samples,71 '_exp': self.exp_samples,72 '_spk': self.spikein_samples,...
test.py
Source: test.py
...50 args = parser.parse_args()51 if 'LOCAL_RANK' not in os.environ:52 os.environ['LOCAL_RANK'] = str(args.local_rank)53 return args54def merge_configs(cfg1, cfg2):55 # Merge cfg2 into cfg156 # Overwrite cfg1 if repeated, ignore if value is None.57 cfg1 = {} if cfg1 is None else cfg1.copy()58 cfg2 = {} if cfg2 is None else cfg259 for k, v in cfg2.items():60 if v:61 cfg1[k] = v62 return cfg163def main():64 args = parse_args()65 cfg = mmcv.Config.fromfile(args.config)66 # Load output_config from cfg67 output_config = cfg.get('output_config', {})68 # Overwrite output_config from args.out69 output_config = merge_configs(output_config, dict(out=args.out))70 # Load eval_config from cfg71 eval_config = cfg.get('eval_config', {})72 # Overwrite eval_config from args.eval73 eval_config = merge_configs(eval_config, dict(metrics=args.eval))74 # Add options from args.option75 eval_config = merge_configs(eval_config, args.options)76 assert output_config or eval_config, \77 ('Please specify at least one operation (save or eval the '78 'results) with the argument "--out" or "--eval"')79 # set cudnn benchmark80 if cfg.get('cudnn_benchmark', False):81 torch.backends.cudnn.benchmark = True82 cfg.data.test.test_mode = True83 if cfg.test_cfg is None:84 cfg.test_cfg = dict(average_clips=args.average_clips)85 else:86 cfg.test_cfg.average_clips = args.average_clips87 # init distributed env first, since logger depends on the dist info.88 if args.launcher == 'none':89 distributed = False...
config.py
Source: config.py
...11 tiny_db: TinyDbConfig = TinyDbConfig()12class Config(AConfig):13 db: DbDriverConfigOptions = DbDriverConfigOptions()14DEFAULT_CONFIGS = Config()15def merge_configs(config: AConfig, custom_config: Optional[Dict[str, Any]] = None) -> AConfig:16 """Examples:17 >>> default_config_value = "bar"18 >>> class TestConfigClass(AConfig):19 ... class TestConfigClassEmbedded(AConfig):20 ... foo = default_config_value21 ... sub_config = TestConfigClassEmbedded()22 ... foo = default_config_value23 ...24 ... def __str__(self):25 ... return f'foo: {self.foo}, sub_config: foo: {self.sub_config.foo}'26 ...27 >>> def get_test_config():28 ... return TestConfigClass()29 1. merge_configs: returns base config without changes if no custom configs are supplied30 >>> test_config = get_test_config()31 >>> result_config = merge_configs(test_config)32 >>> test_config.foo == result_config.foo == default_config_value33 True34 >>> test_config.sub_config.foo == result_config.sub_config.foo == default_config_value35 True36 2. merge_configs: returns partially merged config values if a partial custom config is given37 >>> test_config = get_test_config()38 >>> custom_config = {'foo': 'zed'}39 >>> result_config = merge_configs(test_config, custom_config)40 >>> result_config.foo == custom_config['foo']41 True42 >>> test_config.sub_config.foo == result_config.sub_config.foo == default_config_value43 True44 3. merge_configs: returns fully merged config values if full custom config is given45 >>> test_config = get_test_config()46 >>> custom_config = {'foo': 'zed', 'sub_config': {'foo': 'zar'}}47 >>> result_config = merge_configs(test_config, custom_config)48 >>> result_config.foo == custom_config['foo']49 True50 >>> result_config.sub_config.foo == custom_config['sub_config']['foo']51 True52 """53 def _update_config(base_config: AConfig, custom_config: Dict[str, Any]) -> AConfig:54 members = getmembers(base_config)55 for (key, value) in members:56 if isinstance(value, AConfig) and key in custom_config:57 _update_config(value, custom_config[key])58 elif key in custom_config and not hasattr(value, '__dict__'):59 setattr(base_config, key, custom_config[key])60 return base_config61 return _update_config(config, custom_config) if custom_config else config62def initialize_custom_configs(config_path: str) -> AConfig:63 with open(config_path) as file:64 custom_config: Dict[str, Any] = json.load(file)65 base_configs = Config()...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!