|
28 | 28 | print("") |
29 | 29 |
|
30 | 30 | # Check variable availability |
| 31 | +print("example.py: === value availability tests ===") |
31 | 32 | print("example.py: check for config.empty variable availability is ", end="") |
32 | 33 | try: |
33 | 34 | if "config.empty" in cfg: |
34 | 35 | print("passed, but should fail !!!") |
35 | 36 | else: |
36 | 37 | print("failed, as expected") |
37 | 38 | except Exception: |
38 | | - print("failed, as expected") |
| 39 | + print("failed (exception)") |
39 | 40 |
|
40 | 41 | print("example.py: check for wrong.table variable availability is ", end="") |
41 | 42 | try: |
|
44 | 45 | else: |
45 | 46 | print("failed, as expected") |
46 | 47 | except Exception: |
47 | | - print("failed, as expected") |
| 48 | + print("failed (exception)") |
48 | 49 |
|
49 | 50 | print("example.py: check for empty variable availability is ", end="") |
50 | 51 | try: |
|
53 | 54 | else: |
54 | 55 | print("failed, as expected") |
55 | 56 | except Exception: |
56 | | - print("failed, as expected") |
| 57 | + print("failed (exception)") |
57 | 58 |
|
58 | 59 | print("example.py: check for config.value variable availability is ", end="") |
59 | 60 | try: |
|
62 | 63 | else: |
63 | 64 | print("failed, as expected") |
64 | 65 | except Exception: |
65 | | - print("failed, as expected") |
| 66 | + print("failed (exception)") |
66 | 67 |
|
67 | 68 | print("example.py: check for config.sub.string variable availability is ", end="") |
68 | 69 | try: |
|
71 | 72 | else: |
72 | 73 | print("failed, but should pass !!!") |
73 | 74 | except Exception: |
74 | | - print("failed, but should pass !!!") |
| 75 | + print("failed (exception)") |
75 | 76 |
|
76 | 77 | print("example.py: check for config.sub variable availability is ", end="") |
77 | 78 | try: |
|
80 | 81 | else: |
81 | 82 | print("failed, but should pass !!!") |
82 | 83 | except Exception: |
83 | | - print("failed, but should pass !!!") |
84 | | - |
85 | | -print(f"example.py: config.value is not selected for export, so cfg['config.value'] = {cfg.get('config.value', 'NOT_FOUND')}") |
86 | | -print(f"example.py: config.empty is not found in lua config file, so cfg['config.empty'] = {cfg.get('config.empty', 'NOT_FOUND')}") |
87 | | -print(f"example.py: cfg['config.paths.tempdir'] = {cfg.get('config.paths.tempdir', 'NOT_FOUND')}") |
88 | | -print(f"example.py: cfg['config.paths.workdir'] = {cfg.get('config.paths.workdir', 'NOT_FOUND')}") |
89 | | -print(f"example.py: cfg['config.paths.dynpath'] = {cfg.get('config.paths.dynpath', 'NOT_FOUND')}") |
90 | | -print(f"example.py: cfg['config.paths.tempdir_raw'] = {cfg.get('config.paths.tempdir_raw', 'NOT_FOUND')}") |
91 | | -print(f"example.py: cfg['config.paths.workdir_raw'] = {cfg.get('config.paths.workdir_raw', 'NOT_FOUND')}") |
92 | | -print(f"example.py: cfg['config.paths.dynpath_raw'] = {cfg.get('config.paths.dynpath_raw', 'NOT_FOUND')}") |
93 | | -print(f"example.py: cfg['config.sub.lua_v1'] = {cfg.get('config.sub.lua_v1', 'NOT_FOUND')}") |
94 | | -print(f"example.py: cfg['config.sub.lua_v2'] = {cfg.get('config.sub.lua_v2', 'NOT_FOUND')}") |
95 | | -print(f"example.py: cfg['config.sub.lua_v3'] = {cfg.get('config.sub.lua_v3', 'NOT_FOUND')}") |
96 | | -print(f"example.py: cfg['config.sub.lua_num'] = {cfg.get('config.sub.lua_num', 'NOT_FOUND')}") |
97 | | -print(f"example.py: cfg['config.sub.extra_1'] = {cfg.get('config.sub.extra_1', 'NOT_FOUND')}") |
98 | | -print(f"example.py: cfg['config.sub.extra_2'] = {cfg.get('config.sub.extra_2', 'NOT_FOUND')}") |
99 | | -print(f"example.py: cfg['config.sub.number1'] = {cfg.get('config.sub.number1', 'NOT_FOUND')}") |
100 | | -print(f"example.py: cfg['config.sub.string'] = {cfg.get('config.sub.string', 'NOT_FOUND')}") |
101 | | -print(f"example.py: cfg['config.sub.problematic_string'] = {cfg.get('config.sub.problematic_string', 'NOT_FOUND')}") |
102 | | -print(f"example.py: cfg['config.sub.non_latin_string'] = {cfg.get('config.sub.non_latin_string', 'NOT_FOUND')}") |
103 | | -print(f"example.py: (should be empty regardless of fallback value, because it is a container: cfg['config.sub.sub']) = {cfg.get('config.sub.sub', 'NOT_FOUND')}") |
104 | | -print(f"example.py: cfg['config.sub.sub'] as int with fallback value -1) = {cfg.get_int('config.sub.sub',-1)}") |
105 | | -print(f"example.py: cfg['config.sub.sub'] as int with fallback value -1.6) = {cfg.get_int('config.sub.sub',-1.6)}") |
106 | | -print(f"example.py: cfg['config.sub.sub'] as float with fallback value -1.5) = {cfg.get_float('config.sub.sub',-1.5)}") |
107 | | -print(f"example.py: cfg['config.sub.sub.message'] = {cfg.get('config.sub.sub.message', 'NOT_FOUND')}") |
108 | | -print(f"example.py: cfg['config.sub.sub.message2'] = {cfg.get('config.sub.sub.message2', 'NOT_FOUND')}") |
| 84 | + print("failed (exception)") |
| 85 | + |
| 86 | +print("example.py: === value query tests ===") |
| 87 | +print(f"example.py: not selected for export, should return fallback (NOT_FOUND): cfg['config.value'] = {cfg.get('config.value', 'NOT_FOUND')}, type = {cfg.get_type('config.value')}") |
| 88 | +print(f"example.py: not found in config, should return fallback (NOT_FOUND): cfg['config.empty'] = {cfg.get('config.empty', 'NOT_FOUND')}, type = {cfg.get_type('config.empty')}") |
| 89 | +print(f"example.py: cfg['config.paths.tempdir'] = {cfg.get('config.paths.tempdir', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.tempdir')}") |
| 90 | +print(f"example.py: cfg['config.paths.workdir'] = {cfg.get('config.paths.workdir', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.workdir')}") |
| 91 | +print(f"example.py: cfg['config.paths.dynpath'] = {cfg.get('config.paths.dynpath', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.dynpath')}") |
| 92 | +print(f"example.py: cfg['config.paths.tempdir_raw'] = {cfg.get('config.paths.tempdir_raw', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.tempdir_raw')}") |
| 93 | +print(f"example.py: cfg['config.paths.workdir_raw'] = {cfg.get('config.paths.workdir_raw', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.workdir_raw')}") |
| 94 | +print(f"example.py: cfg['config.paths.dynpath_raw'] = {cfg.get('config.paths.dynpath_raw', 'NOT_FOUND')}, type = {cfg.get_type('config.paths.dynpath_raw')}") |
| 95 | +print(f"example.py: cfg['config.sub.lua_v1'] = {cfg.get('config.sub.lua_v1', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.lua_v1')}") |
| 96 | +print(f"example.py: cfg['config.sub.lua_v2'] = {cfg.get('config.sub.lua_v2', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.lua_v2')}") |
| 97 | +print(f"example.py: cfg['config.sub.lua_v3'] = {cfg.get('config.sub.lua_v3', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.lua_v3')}") |
| 98 | +print(f"example.py: cfg['config.sub.lua_num'] = {cfg.get('config.sub.lua_num', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.lua_num')}") |
| 99 | +print(f"example.py: cfg['config.sub.extra_1'] = {cfg.get('config.sub.extra_1', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.extra_1')}") |
| 100 | +print(f"example.py: cfg['config.sub.extra_2'] = {cfg.get('config.sub.extra_2', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.extra_2')}") |
| 101 | +print(f"example.py: cfg['config.sub.number1'] = {cfg.get('config.sub.number1', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.number1')}") |
| 102 | +print(f"example.py: cfg['config.sub.number2'] = {cfg.get('config.sub.number2', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.number2')}") |
| 103 | +print(f"example.py: cfg['config.sub.string'] = {cfg.get('config.sub.string', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.string')}") |
| 104 | +print(f"example.py: cfg['config.sub.problematic_string'] = {cfg.get('config.sub.problematic_string', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.problematic_string')}") |
| 105 | +print(f"example.py: cfg['config.sub.non_latin_string'] = {cfg.get('config.sub.non_latin_string', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.non_latin_string')}") |
| 106 | + |
| 107 | +# Test table access |
| 108 | +print("example.py: === table tests for cfg['config.sub.sub'] ===") |
| 109 | +print(f"example.py: cfg.is_table('config.sub.sub') = {cfg.is_table('config.sub.sub')}, type = {cfg.get_type('config.sub.sub')}") |
| 110 | +print(f"example.py: table value should return fallback (NOT_FOUND): cfg['config.sub.sub'] = {cfg.get('config.sub.sub', 'NOT_FOUND')}") |
| 111 | +print(f"example.py: table value as int should return fallback (-1): cfg['config.sub.sub'] = {cfg.get_int('config.sub.sub',-1)}") |
| 112 | +print(f"example.py: table value as int should return fallback (-1.6 as int == -1): cfg['config.sub.sub'] = {cfg.get_int('config.sub.sub',-1.6)}") |
| 113 | +print(f"example.py: table value as float should return fallback (-1.5): cfg['config.sub.sub'] = {cfg.get_float('config.sub.sub',-1.5)}") |
| 114 | +print("example.py: === table's value tests for cfg['config.sub.sub'] ===") |
| 115 | +print(f"example.py: cfg['config.sub.sub.message'] = {cfg.get('config.sub.sub.message', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.sub.message')}") |
| 116 | +print(f"example.py: cfg['config.sub.sub.message2'] = {cfg.get('config.sub.sub.message2', 'NOT_FOUND')}, type = {cfg.get_type('config.sub.sub.message2')}") |
109 | 117 | print(f"example.py: cfg['config.sub.multiline_string'] = {cfg.get('config.sub.multiline_string', 'NOT_FOUND')}") |
110 | 118 |
|
| 119 | +# Test empty table access |
| 120 | +print("example.py: === empty table tests for cfg['config.sub.empty_table'] ===") |
| 121 | +print(f"example.py: cfg.is_table('config.sub.empty_table') = {cfg.is_table('config.sub.empty_table')}, type = {cfg.get_type('config.sub.empty_table')}") |
| 122 | +print(f"example.py: table value should return fallback (NOT_FOUND): cfg['config.sub.empty_table'] = {cfg.get('config.sub.empty_table', 'NOT_FOUND')}") |
| 123 | +print(f"example.py: table start for cfg['config.sub.empty_table'] = {cfg.get_table_start('config.sub.empty_table')}") |
| 124 | +print(f"example.py: table end for cfg['config.sub.empty_table'] = {cfg.get_table_end('config.sub.empty_table')}") |
| 125 | + |
111 | 126 | # Test mixed table access (indexed and named elements) |
| 127 | +print("example.py: === mixed table tests for cfg['config.sub.mixed'] ===") |
| 128 | +print(f"example.py: cfg.is_table('config.sub.mixed') = {cfg.is_table('config.sub.mixed')}, type = {cfg.get_type('config.sub.mixed')}") |
112 | 129 | print(f"example.py: table start for config.sub.mixed: {cfg.get_table_start('config.sub.mixed')}") |
113 | 130 | print(f"example.py: table end for config.sub.mixed: {cfg.get_table_end('config.sub.mixed')}") |
114 | 131 | print(f"example.py: table indices sequence for config.sub.mixed: {cfg.get_table_seq('config.sub.mixed')}") |
|
0 commit comments