From 111b6e63a488c65e64c3257eaa1327b0a5ada52c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 3 Feb 2016 18:20:17 -0800 Subject: [PATCH] Error when source directory does not exist. Resolves #116. --- sass.py | 6 +++++- sasstests.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sass.py b/sass.py index 0bad78d6..ebd336c6 100644 --- a/sass.py +++ b/sass.py @@ -195,12 +195,16 @@ def _to_importer(priority, func): return tuple(_to_importer(priority, func) for priority, func in importers) +def _raise(e): + raise e + + def compile_dirname( search_path, output_path, output_style, source_comments, include_paths, precision, custom_functions, importers ): fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() - for dirpath, _, filenames in os.walk(search_path): + for dirpath, _, filenames in os.walk(search_path, onerror=_raise): filenames = [ filename for filename in filenames if filename.endswith(('.scss', '.sass')) and diff --git a/sasstests.py b/sasstests.py index 2623c294..ab705462 100644 --- a/sasstests.py +++ b/sasstests.py @@ -847,6 +847,10 @@ def write_file(filename, contents): class CompileDirectoriesTest(unittest.TestCase): + def test_directory_does_not_exist(self): + with pytest.raises(OSError): + sass.compile(dirname=('i_dont_exist_lol', 'out')) + def test_successful(self): with tempdir() as tmpdir: input_dir = os.path.join(tmpdir, 'input')