Skip to content

Honor strip_extension in SassMiddleware #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 11, 2018
Merged
Changes from 1 commit
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
Next Next commit
Simplify warnings capture with pytest
  • Loading branch information
asottile committed Nov 9, 2018
commit 47810313a0e8a3d42eadea15a82ffe0e5aa9e2e8
34 changes: 8 additions & 26 deletions sasstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import tempfile
import traceback
import unittest
import warnings

import pytest
from six import StringIO, b, string_types, text_type
Expand Down Expand Up @@ -424,14 +423,11 @@ def test_compile_string_deprecated_source_comments_line_numbers(self):
color: red;
}'''
expected = sass.compile(string=source, source_comments=True)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning):
actual = sass.compile(
string=source,
source_comments='line_numbers',
)
assert len(w) == 1
assert issubclass(w[-1].category, FutureWarning)
assert expected == actual

def test_compile_filename(self):
Expand Down Expand Up @@ -465,15 +461,12 @@ def test_compile_source_map_deprecated_source_comments_map(self):
filename=filename,
source_map_filename='a.scss.css.map',
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning):
actual, actual_map = sass.compile(
filename=filename,
source_comments='map',
source_map_filename='a.scss.css.map',
)
assert len(w) == 1
assert issubclass(w[-1].category, FutureWarning)
assert expected == actual
self.assert_source_map_equal(expected_map, actual_map)

Expand Down Expand Up @@ -595,8 +588,7 @@ def test_output_style(self):
class ManifestTestCase(BaseTestCase):

def test_normalize_manifests(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning) as warninfo:
manifests = Manifest.normalize_manifests({
'package': 'sass/path',
'package.name': ('sass/path', 'css/path'),
Expand All @@ -607,8 +599,7 @@ def test_normalize_manifests(self):
'strip_extension': True,
},
})
assert len(w) == 3
assert all(issubclass(x.category, FutureWarning) for x in w)
assert len(warninfo) == 3
assert len(manifests) == 4
assert isinstance(manifests['package'], Manifest)
assert manifests['package'].sass_path == 'sass/path'
Expand All @@ -635,11 +626,8 @@ def replace_source_path(s, name):
return s.replace('SOURCE', test_source_path(name))

shutil.copytree('test', src_path)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning):
m = Manifest(sass_path='test', css_path='css')
assert len(w) == 1
assert issubclass(w[-1].category, FutureWarning)

m.build_one(d, 'a.scss')
with open(os.path.join(d, 'css', 'a.scss.css')) as f:
Expand Down Expand Up @@ -720,15 +708,12 @@ def test_wsgi_sass_middleware(self):
with tempdir() as css_dir:
src_dir = os.path.join(css_dir, 'src')
shutil.copytree('test', src_dir)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning):
app = SassMiddleware(
self.sample_wsgi_app, {
__name__: (src_dir, css_dir, '/static'),
},
)
assert len(w) == 1
assert issubclass(w[-1].category, FutureWarning)
client = Client(app, Response)
r = client.get('/asdf')
assert r.status_code == 200
Expand Down Expand Up @@ -828,15 +813,12 @@ def test_pysassc_stdout(self):
assert A_EXPECTED_CSS.strip() == self.out.getvalue().strip()

def test_sassc_stdout(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
with pytest.warns(FutureWarning) as warninfo:
exit_code = sassc.main(
['sassc', 'test/a.scss'],
self.out, self.err,
)
assert len(w) == 1
assert issubclass(w[-1].category, FutureWarning)
assert 'use `pysassc`' in str(w[-1].message)
assert 'use `pysassc`' in warninfo[0].message.args[0]
assert exit_code == 0
assert self.err.getvalue() == ''
assert A_EXPECTED_CSS.strip() == self.out.getvalue().strip()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy