From 56c7db6e2b09f8913da9ee0d8d66cb38c11cdd32 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Mon, 4 Aug 2014 11:11:14 +0200 Subject: Add test for path conflicts --- testproject/testproject/static/css/path_conflict.scss | 3 +++ testproject/testproject/static/css/path_conflict/content.scss | 3 +++ tests/test_scss.py | 7 +++++++ 3 files changed, 13 insertions(+) create mode 100644 testproject/testproject/static/css/path_conflict.scss create mode 100644 testproject/testproject/static/css/path_conflict/content.scss diff --git a/testproject/testproject/static/css/path_conflict.scss b/testproject/testproject/static/css/path_conflict.scss new file mode 100644 index 0000000..f672943 --- /dev/null +++ b/testproject/testproject/static/css/path_conflict.scss @@ -0,0 +1,3 @@ +.path_conflict { + color: #000000; +} diff --git a/testproject/testproject/static/css/path_conflict/content.scss b/testproject/testproject/static/css/path_conflict/content.scss new file mode 100644 index 0000000..77c9d58 --- /dev/null +++ b/testproject/testproject/static/css/path_conflict/content.scss @@ -0,0 +1,3 @@ +.content { + color: #000000; +} diff --git a/tests/test_scss.py b/tests/test_scss.py index bc9c6ef..e2e8748 100644 --- a/tests/test_scss.py +++ b/tests/test_scss.py @@ -29,6 +29,9 @@ with open(os.path.join(settings.BASE_DIR, 'testproject', 'static', 'css', 'css_f with open(os.path.join(settings.BASE_DIR, 'testproject', 'static', 'css', '_baz.scss')) as f: BAZ_CONTENTS = f.read() +with open(os.path.join(settings.BASE_DIR, 'testproject', 'static', 'css', 'path_conflict.scss')) as f: + PATH_CONFLICT_CONTENTS = f.read() + class CompilerTestMixin(object): def setUp(self): @@ -84,6 +87,10 @@ class ImportTestMixin(CompilerTestMixin): actual = self.compiler.compile(scss_string='@import "/css/baz";') self.assertEqual(clean_css(actual), clean_css(BAZ_CONTENTS)) + def test_import_conflict(self): + actual = self.compiler.compile(scss_string='@import "/css/path_conflict";') + self.assertEqual(clean_css(actual), clean_css(PATH_CONFLICT_CONTENTS)) + @override_settings(DEBUG=True) class FindersImportTest(ImportTestMixin, TestCase): -- cgit v1.2.1 From c517f87a2c536f6ebd3773b869430572ba3eb811 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 4 Aug 2014 10:18:49 +0200 Subject: Put the original path at the end in get_possible_paths Make it try all the combinations of prefixes and suffixes first, and then try the original path. This way if there is a directory named the same as our file, but without the extension and/or prefix, we don't try to open it and avoid raising IOError. Fixes #10. --- django_pyscss/scss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_pyscss/scss.py b/django_pyscss/scss.py index 7429eba..b4c5981 100644 --- a/django_pyscss/scss.py +++ b/django_pyscss/scss.py @@ -67,7 +67,6 @@ class DjangoScss(Scss): path = path[1:] elif relative_to: # relative import path = os.path.join(relative_to, path) - paths.append(path) dirname, filename = os.path.split(path) name, ext = os.path.splitext(filename) @@ -77,6 +76,7 @@ class DjangoScss(Scss): search_exts = self.supported_extensions for prefix, suffix in product(('_', ''), search_exts): paths.append(os.path.join(dirname, prefix + name + suffix)) + paths.append(path) return paths def _find_source_file(self, filename, relative_to=None): -- cgit v1.2.1