Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorn committed Sep 26, 2023
1 parent 820ddbb commit 2115860
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def plan_validator(module_path, inventory_paths, basedir, tf_var_files=None,

def validate_plan_object(expected_value, plan_value, relative_path, relative_address):
# dictionaries / objects
if isinstance(expected_value, dict):
if isinstance(expected_value, dict) and isinstance(plan_value, dict):
for k in expected_value.keys():
assert k in plan_value, \
f'{relative_path}: {k} is not a valid address in the plan'
Expand All @@ -233,12 +233,12 @@ def validate_plan_object(expected_value, plan_value, relative_path, relative_add
validate_plan_object(v, plan_value[k], relative_path, f'{relative_address}.{k}')

# lists
elif isinstance(expected_value, list):
elif isinstance(expected_value, list) and isinstance(plan_value, list):
assert len(plan_value) == len(expected_value), \
f'{relative_path}: {relative_address} has different length. Got {plan_value}, expected {expected_value}'

for idx, (exp, actual) in enumerate(zip(expected_value, plan_value)):
validate_plan_object(exp, actual, relative_path, f'{relative_address}[{idx}]')
for i, (exp, actual) in enumerate(zip(expected_value, plan_value)):
validate_plan_object(exp, actual, relative_path, f'{relative_address}[{i}]')

# all other objects
else:
Expand Down

0 comments on commit 2115860

Please sign in to comment.