From 6d3de72c0066550bd4b53a98bb528a391db0c1af Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 15 Mar 2022 20:52:09 +0000 Subject: [PATCH] A completely empty config is a valid config --- tests.py | 2 +- unittest/correct-empty.yaml | 6 ++++++ validator/__init__.py | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 unittest/correct-empty.yaml diff --git a/tests.py b/tests.py index 2d8a09d..4684254 100755 --- a/tests.py +++ b/tests.py @@ -73,7 +73,7 @@ def main(): for fn in glob.glob(pattern): tests = tests + 1 unittest, cfg = load_unittest(fn) - if not unittest or not cfg: + if not unittest: errors = errors + 1 continue diff --git a/unittest/correct-empty.yaml b/unittest/correct-empty.yaml new file mode 100644 index 0000000..aa3fe59 --- /dev/null +++ b/unittest/correct-empty.yaml @@ -0,0 +1,6 @@ +test: + description: "A completely empty config file is, ironically, correct" + errors: + count: 0 +--- + diff --git a/validator/__init__.py b/validator/__init__.py index 9fc9a35..13f62af 100644 --- a/validator/__init__.py +++ b/validator/__init__.py @@ -74,6 +74,9 @@ class Validator(object): def validate(self, yaml): ret_rv = True ret_msgs = [] + if not yaml: + return ret_rv, ret_msgs + if self.schema: try: self.logger.debug("Validating against schema %s" % self.schema)