|
24 | 24 | from highcharts_core import constants |
25 | 25 |
|
26 | 26 |
|
| 27 | +ALLOWED_NONE_PROPERTIES = [] |
| 28 | +for item in constants.ALLOWED_NONE_CONTEXTS: |
| 29 | + class_name, prop_name = item.split('.') |
| 30 | + if prop_name not in ALLOWED_NONE_PROPERTIES: |
| 31 | + ALLOWED_NONE_PROPERTIES.append(prop_name) |
| 32 | + |
| 33 | + |
27 | 34 | class State(object): |
28 | 35 | """Class to hold incremental test state.""" |
29 | 36 | # pylint: disable=too-few-public-methods |
@@ -241,12 +248,26 @@ def does_kwarg_value_match_result(kwarg_value, result_value): |
241 | 248 | print('- checking two dict objects') |
242 | 249 | if len(kwarg_value) != len(result_value): |
243 | 250 | print('-- len does not match') |
244 | | - return False |
| 251 | + if len(kwarg_value) > len(result_value): |
| 252 | + extra_in_result = [x for x in result_value if x not in kwarg_value] |
| 253 | + extra_in_kwarg = [x for x in kwarg_value if x not in result_value] |
| 254 | + print(f'-- extra in RESULT: {extra_in_result}') |
| 255 | + print(f'-- extra in KWARG: {extra_in_kwarg}') |
| 256 | + return False |
| 257 | + difference = len(result_value) - len(kwarg_value) |
| 258 | + if abs(difference) > 1: |
| 259 | + return False |
245 | 260 | for key in kwarg_value: |
246 | 261 | print(f'CHECKING: {key}') |
247 | 262 | if key == 'patternOptions': |
248 | 263 | matches = does_kwarg_value_match_result(kwarg_value.get(key), |
249 | 264 | result_value.get('pattern')) |
| 265 | + elif key in ALLOWED_NONE_PROPERTIES: |
| 266 | + if kwarg_value.get(key, None) is None and result_value.get(key) is None: |
| 267 | + continue |
| 268 | + else: |
| 269 | + matches = does_kwarg_value_match_result(kwarg_value.get(key), |
| 270 | + result_value.get(key)) |
250 | 271 | else: |
251 | 272 | matches = does_kwarg_value_match_result(kwarg_value.get(key), |
252 | 273 | result_value.get(key)) |
@@ -303,7 +324,7 @@ def trim_expected_dict(expected): |
303 | 324 | if not isinstance(expected, dict): |
304 | 325 | return expected |
305 | 326 | for key in expected: |
306 | | - if expected[key] is None: |
| 327 | + if expected[key] is None and key not in ALLOWED_NONE_PROPERTIES: |
307 | 328 | continue |
308 | 329 | elif isinstance(expected[key], dict): |
309 | 330 | trimmed_value = trim_expected_dict(expected[key]) |
|
0 commit comments