How to use process_config_path method in avocado

Best Python code snippet using avocado_python

settings.py

Source:settings.py Github

copy

Full Screen

...138 config_path_local,139 config_path_intree])140 if config_intree:141 # In this case, respect only the intree config142 self.process_config_path(config_path_intree)143 if config_intree_extra:144 for extra_file in glob.glob(os.path.join(_config_path_intree_extra, '*.conf')):145 self.process_config_path(extra_file)146 self.intree = True147 else:148 # In this case, load first the global config, then the149 # local config overrides the global one150 if config_system:151 self.process_config_path(config_path_system)152 if config_system_extra:153 for extra_file in glob.glob(os.path.join(_config_dir_system_extra, '*.conf')):154 self.process_config_path(extra_file)155 if not config_local:156 path.init_dir(_config_dir_local)157 with open(config_path_local, 'w') as config_local_fileobj:158 config_local_fileobj.write('# You can use this file to override configuration values from '159 '%s and %s\n' % (config_path_system, _config_dir_system_extra))160 else:161 self.process_config_path(config_path_local)162 else:163 # Unittests164 self.process_config_path(config_path)165 def process_config_path(self, pth):166 read_configs = self.config.read(pth)167 if read_configs:168 self.config_paths += read_configs169 else:170 self.config_paths_failed.append(pth)171 def _handle_no_value(self, section, key, default):172 """173 What to do if key in section has no value.174 :param section: Config file section.175 :param key: Config file key, relative to section.176 :param default: Default value for key, in case it does not exist.177 :returns: Default value, if a default value was provided.178 :raises: SettingsError, in case no default was provided.179 """...

Full Screen

Full Screen

test_future_settings.py

Source:test_future_settings.py Github

copy

Full Screen

...17 """Config file options that are not registered should be ignored.18 This should force plugins to run register_option().19 """20 stgs = settings.Settings()21 stgs.process_config_path(self.config_file.name)22 config = stgs.as_dict()23 self.assertIsNone(config.get('foo.non_registered'))24 def test_override_default(self):25 """Test if default option is being overwritten by configfile."""26 stgs = settings.Settings()27 stgs.process_config_path(self.config_file.name)28 default = 'default from code'29 stgs.register_option(section='foo',30 key='bar',31 default=default,32 help_msg='just a test')33 stgs.merge_with_configs()34 config = stgs.as_dict()35 self.assertEqual(config.get('foo.bar'), 'default from file')36 def test_non_existing_key(self):37 stgs = settings.Settings()38 stgs.process_config_path(self.config_file.name)39 config = stgs.as_dict()40 self.assertIsNone(config.get('foo.non_existing'))41 def test_bool(self):42 stgs = settings.Settings()43 stgs.process_config_path(self.config_file.name)44 stgs.register_option(section='foo',45 key='bar',46 default=False,47 key_type=bool,48 help_msg='just a test')49 config = stgs.as_dict()50 result = config.get('foo.bar')51 self.assertIsInstance(result, bool)52 self.assertFalse(result)53 def test_string(self):54 stgs = settings.Settings()55 stgs.process_config_path(self.config_file.name)56 stgs.register_option(section='foo',57 key='bar',58 default='just a test',59 help_msg='just a test')60 config = stgs.as_dict()61 result = config.get('foo.bar')62 self.assertIsInstance(result, str)63 self.assertEqual(result, 'just a test')64 def test_list(self):65 stgs = settings.Settings()66 stgs.process_config_path(self.config_file.name)67 stgs.register_option(section='foo',68 key='bar',69 key_type=list,70 default=[],71 help_msg='just a test')72 config = stgs.as_dict()73 result = config.get('foo.bar')74 self.assertIsInstance(result, list)75 self.assertEqual(0, len(result))76 def test_add_argparser(self):77 stgs = settings.Settings()78 stgs.process_config_path(self.config_file.name)79 stgs.register_option('section', 'key', 'default', 'help')80 parser = argparse.ArgumentParser(description='description')81 stgs.add_argparser_to_option('section.key', parser, '--long-arg')82 with self.assertRaises(settings.SettingsError):83 stgs.add_argparser_to_option('section.key', parser, '--other-arg')84 stgs.add_argparser_to_option('section.key', parser, '--other-arg',85 allow_multiple=True)86 def test_multiple_parsers(self):87 stgs = settings.Settings()88 stgs.process_config_path(self.config_file.name)89 parser1 = argparse.ArgumentParser(description='description')90 stgs.register_option('section', 'key', 'default', 'help',91 parser=parser1, long_arg='--first-option')92 parser2 = argparse.ArgumentParser(description='other description')93 with self.assertRaises(settings.DuplicatedNamespace):94 stgs.register_option('section', 'key', 'default', 'help',95 parser=parser2, long_arg='--other-option')96 stgs.register_option('section', 'key', 'default', 'help',97 parser=parser2, long_arg='--other-option',98 allow_multiple=True)99 self.assertIs(stgs._namespaces['section.key'].parser, parser2)100 def test_filter(self):101 stgs = settings.Settings()102 stgs.process_config_path(self.config_file.name)103 stgs.register_option(section='foo',104 key='bar',105 default='default from file',106 help_msg='just a test')107 stgs.register_option(section='foo',108 key='baz',109 default='other default from file',110 help_msg='just a test')111 self.assertEqual(stgs.as_dict(r'foo.bar$'),112 {'foo.bar': 'default from file'})113 def tearDown(self):114 os.unlink(self.config_file.name)115class ConfigOption(unittest.TestCase):116 def test_as_list(self):...

Full Screen

Full Screen

process_config.py

Source:process_config.py Github

copy

Full Screen

1import os2import pickle3class ProcessConfig:4 otypes: list5 acts: list6 activitySelectedTypes: dict7 activityLeadingTypes: dict8 otypeLeadingActivities: dict9 nonEmittingTypes: list10 @classmethod11 def load(cls, session_path):12 process_config_path = os.path.join(session_path, "process_config.pkl")13 return pickle.load(open(process_config_path, "rb"))14 def __init__(self, config_dto, session_path):15 self.session_path = session_path16 self.acts = config_dto["acts"]17 self.nonEmittingTypes = config_dto["non_emitting_types"]18 self.activitySelectedTypes = config_dto["activity_selected_types"]19 self.activityLeadingTypes = config_dto["activity_leading_type_selections"]20 self.otypes = [otype for otype in config_dto["otypes"]21 if any(otype in self.activitySelectedTypes[act] for act in self.acts)]22 self.otypeLeadingActivities = {23 otype: [act for act, ot in self.activityLeadingTypes.items() if ot == otype]24 for otype in self.otypes25 }26 def save(self):27 process_config_path = os.path.join(self.session_path, "process_config.pkl")28 with open(process_config_path, "wb") as write_file:29 pickle.dump(self, write_file)30 @classmethod31 def update_non_emitting_types(cls, session_path, non_emitting_types_str):32 process_config: ProcessConfig = cls.load(session_path)33 process_config.nonEmittingTypes = non_emitting_types_str.split(",") if len(non_emitting_types_str) > 0 else []...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful