def test_lconf_structure_classes6(): """ Tests: test_lconf_structure_classes6 """ print('::: TEST: test_lconf_structure_classes6()') obj_ = KVList(True, ['1', '2']) obj_.set_class__dict__item('mydata', 'new value') eq_(obj_.mydata, 'new value', msg=None)
def test_lconf_emit_default_obj__ok2(): """ Tests: test_lconf_emit_default_obj__ok2 """ print('::: TEST: test_lconf_emit_default_obj__ok2()') lconf_section__template_obj = Root([ ('first', 'Paul'), ('last', 'Smith'), ('sex', 'm'), ('age', '39', lconf_to_int), ('salary', '7000', lconf_to_float), ('interests', KVList(False, ['golf', 'reading', 'investments'])), ('registered', 'true'), ]) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) eq_(section_lines[4], 'age :: 39', msg=None) eq_(section_lines[6], '- interests', msg=None) eq_(section_lines[7], ' golf', msg=None) eq_(section_lines[10], 'registered :: true', msg=None) lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_parse_section_ok0(): """ Tests: test_lconf_parse_section_ok0 """ print('::: TEST: test_lconf_parse_section_ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: Test Example1 # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 # Comment-Line - interests soccer tennis # Comment-Line: `Key :: Value Pair` registered :: False ___END ''' default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=True) lconf_obj = lconf_parse_section(default_lconf_obj, lconf_section_raw_str, lconf_section__template_obj, validate=True) ok_(isinstance(lconf_obj, LconfRoot), msg=None) eq_(lconf_obj['first'], 'Joe', msg=None) eq_(lconf_obj['last'], 'Smith', msg=None) eq_(lconf_obj['sex'], 'm', msg=None) eq_(lconf_obj['age'], '18', msg=None) eq_(lconf_obj['salary'], '12500', msg=None) ok_(isinstance(lconf_obj['interests'], LconfKVList), msg=None) eq_(lconf_obj['interests'], ['soccer', 'tennis'], msg=None) eq_(lconf_obj['interests'].use_oneline, True, msg=None) lconf_obj = lconf_parse_section(default_lconf_obj, lconf_section_raw_str, lconf_section__template_obj, validate=False)
def test_lconf_key_value_list_ok2(): """ Tests: test_lconf_key_value_list_ok2 """ print('::: TEST: test_lconf_key_value_list_ok2()') lconf_section_raw_str = r'''___SECTION :: Example LCONF `Key-Value-List` # Comment-Line: below is a Main `Key-Value-List` - list 1 2 3 ___END''' example_lconf_template = Root([( '#1', '# Comment-Line: below is a Main `Key :: Value-List`: with transform_function - use_oneline is False ' ), ('list', KVList( False, ['default_value1', 'default_value2']), transform_function)]) default_lconf_obj = lconf_prepare_default_obj(example_lconf_template, with_comments=True) lconf_obj = lconf_parse_section(default_lconf_obj, lconf_section_raw_str, example_lconf_template, validate=True) default_lconf_obj = lconf_prepare_default_obj(example_lconf_template, with_comments=False) lconf_obj = lconf_parse_section(default_lconf_obj, lconf_section_raw_str, example_lconf_template, validate=False)
def test_lconf_emit_ok0(): """ Tests: test_lconf_emit_ok0 """ print('::: TEST: test_lconf_emit_ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: Test Example1 # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 # Comment-Line: `Key-Value-List` - interests :: soccer,tennis # Comment-Line: `Key :: Value Pair` registered :: False ___END''' lconf_obj = lconf_parse_section_extract_by_name( lconf_section_raw_str, 'Test Example1', lconf_section__template_obj, with_comments=True, validate=True) emit_result = lconf_emit(lconf_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=True) eq_(lconf_section_raw_str, emit_result, msg=None) reparsed_lconf_obj = lconf_parse_section_extract_by_name( emit_result, 'Test Example1', lconf_section__template_obj, with_comments=True, validate=True) eq_(lconf_obj, reparsed_lconf_obj, msg=None) re_emit_result = lconf_emit(reparsed_lconf_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=True) eq_(lconf_section_raw_str, re_emit_result, msg=None)
def test_lconf_section_splitlines__missing_identifier__expect_failure(): """ Tests: test_lconf_section_splitlines__missing_identifier__expect_failure """ print( '::: TEST: test_lconf_section_splitlines__missing_identifier__expect_failure()' ) lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: Test Example1 # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 # Comment-Line interests soccer tennis # Comment-Line: `Key :: Value Pair` registered :: False ___END ''' lconf_validate_one_section_str(lconf_section_raw_str) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=True) lconf_obj = lconf_parse_section_lines(default_lconf_obj, section_lines, section_name, lconf_section__template_obj)
def test_lconf_emit_default_obj__ok1(): """ Tests: test_lconf_emit_default_obj__ok1 """ print('::: TEST: test_lconf_emit_default_obj__ok1()') lconf_section__template_obj = Root([ ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('interests', KVList(False, [])), ('registered', ''), ]) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) # empty multi line list: `Key-Value-List` eq_(section_lines[6], '- interests', msg=None) eq_(section_lines[8], '___END', msg=None) lconf_validate_one_section_str(lconf_section_raw_str) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=True) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_NO, with_comments=True) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_YES, with_comments=True) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_NO, with_comments=False) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_YES, with_comments=False)
def test_lconf_parse_section_extract_by_name_expect_failure1(): """ Tests: test_lconf_parse_section_extract_by_name_expect_failure1 """ print( '::: TEST: test_lconf_parse_section_extract_by_name_expect_failure1()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: Test Example1 # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 # Comment-Line - interests soccer tennis # Comment-Line: `Key :: Value Pair` registered :: False ___END ''' lconf_obj = lconf_parse_section_extract_by_name( lconf_section_raw_str, 'Wrong Section Name', lconf_section__template_obj, with_comments=True, validate=True)
def test_lconf_emit_default_obj__ok4(): """ Tests: test_lconf_emit_default_obj__ok4 """ print('::: TEST: test_lconf_emit_default_obj__ok4()') lconf_section__template_obj = Root([ ('interests', KVList(False, ['golf', 'reading', 'investments'])), ]) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Example1', onelinelists=LCONF_YES, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=True) eq_(section_lines[1], '- interests :: golf,reading,investments', msg=None) lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_prepare_default_obj__ok1(): """ Tests: test_lconf_prepare_default_obj__ok1 """ print('::: TEST: test_lconf_prepare_default_obj__ok1()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', '', None, 'NOT-DEFINED'), ('age', '', lconf_to_int, -1), ('salary', 0.0, lconf_to_float), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', True, lconf_to_bool), ]) default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=False) eq_(default_lconf_obj.key_empty_replacementvalue, { 'age': -1, 'sex': 'NOT-DEFINED' }, msg=None) eq_(type(default_lconf_obj['age']), int, msg=None) eq_(default_lconf_obj['age'], -1, msg=None) # `Empty-KeyValuePair-ReplacementValues` eq_(type(default_lconf_obj['salary']), float, msg=None) eq_(type(default_lconf_obj['registered']), bool, msg=None) default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=True) eq_(default_lconf_obj.key_empty_replacementvalue, { 'age': -1, 'sex': 'NOT-DEFINED' }, msg=None)
def test_lconf_prepare_default_obj__ok0(): """ Tests: test_lconf_prepare_default_obj__ok0 """ print('::: TEST: test_lconf_prepare_default_obj__ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', '', None, 'NOT-DEFINED'), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=False) eq_(default_lconf_obj.key_order, ['first', 'last', 'sex', 'age', 'salary', 'interests', 'registered'], msg=None) eq_(default_lconf_obj.key_empty_replacementvalue, {'sex': 'NOT-DEFINED'}, msg=None) eq_(default_lconf_obj.has_comments, False, msg=None) eq_(type(default_lconf_obj['age']), str, msg=None) eq_(default_lconf_obj['age'], '', msg=None) default_lconf_obj = lconf_prepare_default_obj(lconf_section__template_obj, with_comments=True) eq_(default_lconf_obj.key_order, [ '#1', '#2', 'first', 'last', 'sex', 'age', 'salary', '#3', 'interests', '#4', 'registered' ], msg=None) eq_(default_lconf_obj.has_comments, True, msg=None)
def test_lconf_emit_default_obj__ok3(): """ Tests: test_lconf_emit_default_obj__ok3 """ print('::: TEST: test_lconf_emit_default_obj__ok3()') lconf_section__template_obj = Root([ ('first', 'Paul'), ('#1', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"' ), ('last', 'Smith', None, 'NOT-DEFINED'), ('#2', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"' ), ('sex', '', None, 'NOT-DEFINED'), ('age', '39', lconf_to_int), ('#3', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "-1"' ), ('salary', '', lconf_to_float, -1), ('interests', KVList(False, ['golf', 'reading', 'investments'])), ('registered', 'true'), ]) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) eq_(section_lines[1], 'first :: Paul', msg=None) eq_(section_lines[2], 'last :: Smith', msg=None) eq_(section_lines[3], 'sex ::', msg=None) eq_(section_lines[4], 'age :: 39', msg=None) eq_(section_lines[5], 'salary ::', msg=None) eq_(section_lines[6], '- interests', msg=None) eq_(section_lines[7], ' golf', msg=None) eq_(section_lines[10], 'registered :: true', msg=None) lconf_validate_one_section_str(lconf_section_raw_str)
('key10value_mapping', KVMap([ ('mapping10_key1', ''), ('mapping10_key2', ''), ('mapping10_key3', ''), ('mapping10_key4', ''), ('mapping10_key5', ''), ('mapping10_key6', ''), ])), # Main `Key-Value-Mapping: ('key11value_mapping', KVMap([ ('mapping11_key1', ''), ('mapping11_key2', ''), ])), ('key12list', KVList(True, [])), ('key13value_pairlist', KVList(False, [])), ('key14value_pairlist', KVList(False, ['1', '2', '3'])), # Repeated Mapping-Block Identifier: ('RepeatedBlk1', BlkI(2, 5, Blk([ # Block-Item `Key-Value-Mapping` ('MyKey1mapping', KVMap([ ('blk_mapping_key1', ''), ('blk_mapping_key2', ''), ('blk_mapping_key3', ''), ])), ('MyKey2', ''),
def test_lconf_to_ordered_native_type_ok0(): """ Tests: test_lconf_to_ordered_native_type_ok0 """ print('::: TEST: test_lconf_to_ordered_native_type_ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: EXAMPLE 1 #1 :: #2 :: # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 #3 :: # Comment-Line: `Key-Value-List` - interests soccer tennis #4 :: # Comment-Line: `Key :: Value Pair` registered :: False ___END''' lconf_obj = lconf_parse_section_extract_by_name( lconf_section_raw_str, 'EXAMPLE 1', lconf_section__template_obj, with_comments=True, validate=True ) result_ordered_native_type = lconf_to_ordered_native_type(lconf_obj) ok_(isinstance(lconf_obj, LconfRoot), msg=None) ok_(isinstance(result_ordered_native_type, OrderedDict), msg=None) ok_(isinstance(lconf_obj['interests'], LconfKVList), msg=None) ok_(isinstance(result_ordered_native_type['interests'], list), msg=None) # RE DUMP AS JSON re_dump_json = json_dumps(result_ordered_native_type, indent=3) # RE CONVERT TO LCONF result_reconverted_dict_to_lconf2 = lconf_dict_to_lconf( json_loads(re_dump_json, object_pairs_hook=OrderedDict), 'EXAMPLE 1', onelinelists=False, skip_none_value=False ) eq_(lconf_section_raw_str, result_reconverted_dict_to_lconf2, msg=None)
def test_lconf_structure_classes0_expect_failure5(): """ Tests: test_lconf_structure_classes0_expect_failure5 """ print('::: TEST: test_lconf_structure_classes0_expect_failure5()') KVList(True, ('1', '2'))
( 'key10value_mapping', KVMap([ ('#8', '# Comment-Line: Key-Value-Mapping items: are `Key :: Value Pairs`' ), ('mapping10_key1', ''), ('mapping10_key2', False, lconf_to_bool), ('mapping10_key3', 0, lconf_to_int), # `Key :: Value-List` or `Key-Value-List`: type: KVList: set default_is_oneline: True ('#9a', ''), ('#9b', '# Comment-Line: Key-Value-Mapping item: `Key :: Value-List` or `Key-Value-List`' ), ('mapping10_key4_list', KVList(True, [555, 9999]), lconf_to_int), # `Key :: Value-List` or `Key-Value-List`: type: KVList: set default_is_oneline: False ('#10', ''), ('#11', '# Comment-Line: Key-Value-Mapping item: `Key :: Value-List` or `Key-Value-List`' ), ('mapping10_key5_list', KVList(False, [555, 9999]), lconf_to_int), # `List-Of-Tuples`: type: ListOT: one transform function for all values ('#12', ''), ('#13', '# Comment-Line: Key-Value-Mapping item: `List-Of-Tuples`'), ('mapping10_key6_list', ListOT(('x', 'y'), [(9999, 9999), (9999, 9999)]), lconf_to_int),
def test_lconf_emit_default_obj__ok0(): """ Tests: test_lconf_emit_default_obj__ok0 """ print('::: TEST: test_lconf_emit_default_obj__ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=True) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) # empty comment line eq_(section_lines[1], '', msg=None) eq_(section_lines[8], '# Comment-Line: `Key-Value-List`', msg=None) eq_(section_lines[9], '- interests ::', msg=None) eq_(section_lines[12], '___END', msg=None) lconf_validate_one_section_str(lconf_section_raw_str) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_NO, with_comments=True) lconf_validate_one_section_str(lconf_section_raw_str) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_YES, with_comments=True) lconf_validate_one_section_str(lconf_section_raw_str) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_DEFAULT, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) # empty multi line list: `Key :: Value-List` eq_(section_lines[6], '- interests ::', msg=None) eq_(section_lines[8], '___END', msg=None) lconf_validate_one_section_str(lconf_section_raw_str) # lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_NO, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) # empty multi line list: `Key :: Value-List` eq_(section_lines[6], '- interests', msg=None) eq_(section_lines[8], '___END', msg=None) lconf_validate_one_section_str(lconf_section_raw_str) lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj, 'Test Example1', onelinelists=LCONF_YES, with_comments=False) section_lines, section_name = lconf_section_splitlines( lconf_section_raw_str, validate_first_line=False) eq_(section_lines[0], '___SECTION :: Test Example1', msg=None) # empty multi line list: `Key :: Value-List` eq_(section_lines[6], '- interests ::', msg=None) eq_(section_lines[8], '___END', msg=None) lconf_validate_one_section_str(lconf_section_raw_str)
lconf_section__example_4a__template_obj = Root([ # Default Empty Line ('#1', ''), ('registered_employees', 0, lconf_to_int), ('#2', '# Comment-Line: `Repeated-Block-Identifier`'), ('Employee', BlkI(-1, -1, Blk([ ('first', ''), ('last', ''), ('sex', ''), ('age', ''), ('past_salary', KVMap([ ('year2012', ''), ('year2013', -1, lconf_to_int), ])), ('emails', KVList(True, [])), ]), )), ('registered_customer', 0, lconf_to_int), ('#3', '# Comment-Line: `List-Of-Tuples`'), ('accounting', ListOT(('item1', 'item2', 'item3', 'item4'), [])), ]) lconf_section__example_4a_lconf_section_raw_str = r'''___SECTION :: EXAMPLE 4 a registered_employees :: 28594 * Employee Person1 first :: John last :: Doe sex :: M age :: 39
def test_lconf_to_native_type_ok0(): """ Tests: test_lconf_to_native_type_ok0 """ print('::: TEST: test_lconf_to_native_type_ok0()') lconf_section__template_obj = Root([ # Default Empty Line ('#1', ''), # Default Comment Line ('#2', '# Comment-Line: `Key :: Value Pair`'), ('first', ''), ('last', '', None, 'NOT-DEFINED'), ('sex', '', None, 'NOT-DEFINED'), ('age', '', lconf_to_int, -1), ('salary', ''), ('#3', '# Comment-Line: `Key-Value-List`'), ('interests', KVList(True, [])), ('#4', '# Comment-Line: `Key :: Value Pair`'), ('registered', ''), ]) lconf_section_raw_str = r'''___SECTION :: EXAMPLE 1 #1 :: #2 :: # Comment-Line: `Key :: Value Pair` first :: Joe last :: Smith sex :: m age :: 18 salary :: 12500 #3 :: # Comment-Line: `Key-Value-List` - interests soccer tennis #4 :: # Comment-Line: `Key :: Value Pair` registered :: False ___END''' lconf_obj = lconf_parse_section_extract_by_name( lconf_section_raw_str, 'EXAMPLE 1', lconf_section__template_obj, with_comments=False, validate=True) result_native_type = lconf_to_native_type(lconf_obj) ok_(isinstance(lconf_obj, LconfRoot), msg=None) ok_(isinstance(result_native_type, dict), msg=None) ok_(isinstance(lconf_obj['interests'], LconfKVList), msg=None) ok_(isinstance(result_native_type['interests'], list), msg=None) ok_(lconf_obj['last'] == result_native_type['last'] == 'Smith', msg=None) ok_(lconf_obj['age'] == result_native_type['age'] == 18, msg=None) # RE DUMP AS JSON re_dump_json = json_dumps(result_native_type, indent=3) # RE CONVERT TO LCONF result_reconverted_dict_to_lconf2 = lconf_dict_to_lconf( json_loads(re_dump_json), 'EXAMPLE 1', onelinelists=False, skip_none_value=False) lconf_validate_one_section_str(result_reconverted_dict_to_lconf2) if has_yaml: dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True) parsed_load_yaml = yaml_load(dump_yaml) ok_(isinstance(parsed_load_yaml, dict), msg=None) ok_(isinstance(parsed_load_yaml['interests'], list), msg=None) ok_(parsed_load_yaml['last'] == lconf_obj['last'] == result_native_type['last'] == 'Smith', msg=None) ok_(parsed_load_yaml['age'] == lconf_obj['age'] == result_native_type['age'] == 18, msg=None)