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()
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', }
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()
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() == ''
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() == ''
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)
def main(*args, **kwargs): warnings.warn( 'The `sassc` entrypoint is deprecated, please use `pysassc`', FutureWarning, ), return pysassc.main(*args, **kwargs)
def test_pysassc_warning_import_extensions(self): with pytest.warns(FutureWarning): pysassc.main( ['pysassc', os.devnull, '--import-extensions', '.css'], )
def main(*args, **kwargs): warnings.warn( "The `sassc` entrypoint is deprecated, please use `pysassc`", FutureWarning, ), return pysassc.main(*args, **kwargs)