Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions sasstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,32 @@ def test_wsgi_sass_middleware_without_extension(self):
self.assertEqual(expected.encode(), r.data)
assert r.mimetype == 'text/css'

def test_wsgi_sass_middleware_without_extension_sass(self):
with tempdir() as css_dir:
src_dir = os.path.join(css_dir, 'src')
os.makedirs(src_dir)
with open(os.path.join(src_dir, 'a.sass'), 'w') as f:
f.write('a\n\tb\n\t\tcolor: blue;')
app = SassMiddleware(
self.sample_wsgi_app, {
__name__: {
'sass_path': src_dir,
'css_path': css_dir,
'wsgi_path': '/static',
'strip_extension': True,
},
},
)
client = Client(app, Response)
r = client.get('/static/a.css')
assert r.status_code == 200
expected = (
'a b {\n color: blue; }\n\n'
'/*# sourceMappingURL=../a.css.map */'
)
self.assertEqual(expected.encode(), r.data)
assert r.mimetype == 'text/css'


class DistutilsTestCase(BaseTestCase):

Expand Down
10 changes: 8 additions & 2 deletions sassutils/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ def unresolve_filename(self, filename):
"""
filename, _ = os.path.splitext(filename)
if self.strip_extension:
filename = filename + '.scss'
return filename
for ext in ('.scss', '.sass'):
test_path = os.path.join(self.sass_path, filename + ext)
if os.path.exists(test_path):
return filename + ext
else: # file not found, let it error with `.scss` extension
return filename + '.scss'
else:
return filename

def build(self, package_dir, output_style='nested'):
"""Builds the Sass/SCSS files in the specified :attr:`sass_path`.
Expand Down