Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mobly/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ def load_test_config_file(test_config_path, tb_filters=None):
# Deprecated, use testbed_name
test_run_config.test_bed_name = test_run_config.testbed_name
test_run_config.log_path = log_path
test_run_config.controller_configs = original_bed_config.get(
keys.Config.key_testbed_controllers.value, {}
# An empty section in YAML (e.g. a bare `TestParams:`) loads as None.
test_run_config.controller_configs = (
original_bed_config.get(keys.Config.key_testbed_controllers.value) or {}
)
test_run_config.user_params = original_bed_config.get(
keys.Config.key_testbed_test_params.value, {}
test_run_config.user_params = (
original_bed_config.get(keys.Config.key_testbed_test_params.value) or {}
)
test_configs.append(test_run_config)
return test_configs
Expand Down
12 changes: 12 additions & 0 deletions tests/mobly/config_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ def test__load_config_file_with_unicode(self):
config = config_parser._load_config_file(tmp_file_path)
self.assertEqual(config['TestBeds'][0]['Name'], '\u901a')

def test_load_test_config_file_with_empty_sections(self):
tmp_file_path = os.path.join(self.tmp_dir, 'config.yml')
with io.open(tmp_file_path, 'w', encoding='utf-8') as f:
f.write('TestBeds:\n')
f.write(' - Name: SampleTestBed\n')
f.write(' Controllers:\n')
f.write(' TestParams:\n')

config = config_parser.load_test_config_file(tmp_file_path)[0]
self.assertEqual(config.controller_configs, {})
self.assertEqual(config.user_params, {})

def test_run_config_type(self):
config = config_parser.TestRunConfig()
self.assertNotIn('summary_writer', str(config))
Expand Down