Browse Source

test(device_config): handle missing line in path

Jason Rumney 1 week ago
parent
commit
08835248a1
1 changed files with 4 additions and 1 deletions
  1. 4 1
      tests/test_device_config.py

+ 4 - 1
tests/test_device_config.py

@@ -519,7 +519,10 @@ def test_config_files_parse(mocker):
                 path = ".".join([str(p) for p in err.path])
                 messages.append(f"{path}: {err.msg}")
                 if first_line is None:
-                    first_line = err.path[-1].__line__
+                    # voluptuous doesn't always seem to return line numbers
+                    if err.path and hasattr(err.path[-1], "__line__"):
+                        first_line = err.path[-1].__line__
+
             messages = "; ".join(messages)
             if not first_line:
                 first_line = 1