From 2318c792d7cdcd6ffd5502e9747f95e38f3a7fe8 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Tue, 30 Dec 2014 22:06:01 -0700 Subject: [PATCH] Fix test cdist_type.TypeTestCase.test_directory_in_default --- cdist/core/cdist_type.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index ff1ebaec..d5b4ea3e 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -204,11 +204,13 @@ class CdistType(object): try: defaults_dir = os.path.join(self.absolute_path, "parameter", "default") for name in os.listdir(defaults_dir): - with open(os.path.join(defaults_dir, name)) as fd: - defaults[name] = fd.read().strip() + try: + with open(os.path.join(defaults_dir, name)) as fd: + defaults[name] = fd.read().strip() + except EnvironmentError: + pass # Swallow errors raised by open() or read() except EnvironmentError: - # error ignored - pass + pass # Swallow error raised by os.listdir() finally: self.__parameter_defaults = defaults return self.__parameter_defaults