예제 #1
0
 def test_no_args(self):
     exit_code = pysassc.main(['pysassc'], self.out, self.err)
     assert exit_code == 2
     err = self.err.getvalue()
     assert err.strip().endswith('error: too few arguments'), \
         'actual error message is: ' + repr(err)
     assert '' == self.out.getvalue()
예제 #2
0
def test_pysassc_sourcemap(tmpdir):
    src_file = tmpdir.join('src').ensure_dir().join('a.scss')
    out_file = tmpdir.join('a.scss.css')
    out_map_file = tmpdir.join('a.scss.css.map')

    src_file.write('.c { font-size: 5px + 5px; }')

    exit_code = pysassc.main([
        'pysassc', '-m', src_file.strpath, out_file.strpath,
    ])
    assert exit_code == 0

    contents = out_file.read()
    assert contents == (
        '.c {\n'
        '  font-size: 10px; }\n'
        '\n'
        '/*# sourceMappingURL=a.scss.css.map */'
    )
    source_map_json = json.loads(out_map_file.read())
    assert source_map_json == {
        'sources': ['src/a.scss'],
        'version': 3,
        'names': [],
        'file': 'a.scss.css',
        'mappings': 'AAAA,AAAA,EAAE,CAAC;EAAE,SAAS,EAAE,IAAS,GAAI',
    }
예제 #3
0
 def test_pysassc_stdout(self):
     exit_code = pysassc.main(
         ['pysassc', 'test/a.scss'],
         self.out, self.err,
     )
     assert exit_code == 0
     assert self.err.getvalue() == ''
     assert A_EXPECTED_CSS.strip() == self.out.getvalue().strip()
예제 #4
0
 def test_three_args(self):
     exit_code = pysassc.main(
         ['pysassc', 'a.scss', 'b.scss', 'c.scss'],
         self.out, self.err,
     )
     assert exit_code == 2
     err = self.err.getvalue()
     assert err.strip().endswith('error: too many arguments'), \
         'actual error message is: ' + repr(err)
     assert self.out.getvalue() == ''
예제 #5
0
 def test_pysassc_source_map_without_css_filename(self):
     exit_code = pysassc.main(
         ['pysassc', '-m', 'a.scss'],
         self.out, self.err,
     )
     assert exit_code == 2
     err = self.err.getvalue()
     assert err.strip().endswith(
         'error: -m/-g/--sourcemap requires '
         'the second argument, the output css '
         'filename.',
     ), \
         'actual error message is: ' + repr(err)
     assert self.out.getvalue() == ''
예제 #6
0
 def test_pysassc_output_unicode(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = pysassc.main(
             ['pysassc', 'test/d.scss', tmp],
             self.out, self.err,
         )
         assert exit_code == 0
         assert self.err.getvalue() == ''
         assert self.out.getvalue() == ''
         with io.open(tmp, encoding='UTF-8') as f:
             assert D_EXPECTED_CSS.strip() == f.read().strip()
     finally:
         os.remove(tmp)
예제 #7
0
def main(*args, **kwargs):
    warnings.warn(
        'The `sassc` entrypoint is deprecated, please use `pysassc`',
        FutureWarning,
    ),
    return pysassc.main(*args, **kwargs)
예제 #8
0
 def test_pysassc_warning_import_extensions(self):
     with pytest.warns(FutureWarning):
         pysassc.main(
             ['pysassc', os.devnull, '--import-extensions', '.css'],
         )
예제 #9
0
def main(*args, **kwargs):
    warnings.warn(
        "The `sassc` entrypoint is deprecated, please use `pysassc`", FutureWarning,
    ),
    return pysassc.main(*args, **kwargs)