コード例 #1
0
ファイル: tasks.py プロジェクト: macro1/pythonsd-django
def compile_sass():

    try:  # ensure destination directory exists
        os.makedirs(CSS_DIR)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

    sassc.main(argv=[
        'sassc', SASS,
        '{css_dir}/pythonsd.css'.format(css_dir=CSS_DIR),
        '--output-style=compressed',
    ])
コード例 #2
0
def compile_sass():

    try:  # ensure destination directory exists
        os.makedirs(CSS_DIR)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

    sassc.main(argv=[
        "sassc",
        SASS,
        "{css_dir}/pythonsd.css".format(css_dir=CSS_DIR),
        "--output-style=compressed",
    ])
コード例 #3
0
ファイル: sasstests.py プロジェクト: Magzhan123/TabysKTS
 def test_sassc_sourcemap(self):
     tmp_dir = tempfile.mkdtemp()
     src_dir = os.path.join(tmp_dir, 'test')
     shutil.copytree('test', src_dir)
     src_filename = os.path.join(src_dir, 'a.scss')
     out_filename = os.path.join(tmp_dir, 'a.scss.css')
     try:
         exit_code = sassc.main(
             ['sassc', '-m', src_filename, out_filename],
             self.out, self.err
         )
         self.assertEqual(0, exit_code)
         self.assertEqual('', self.err.getvalue())
         self.assertEqual('', self.out.getvalue())
         with open(out_filename) as f:
             self.assertEqual(
                 A_EXPECTED_CSS_WITH_MAP.replace(
                     'SOURCE', normalize_path(src_filename)
                 ),
                 f.read().strip()
             )
         with open(out_filename + '.map') as f:
             self.assert_source_map_equal(
                 dict(A_EXPECTED_MAP, sources=None),
                 dict(json.load(f), sources=None)
             )
     finally:
         shutil.rmtree(tmp_dir)
コード例 #4
0
def test_sassc_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 = sassc.main([
        'sassc',
        '-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',
    }
コード例 #5
0
 def test_no_args(self):
     exit_code = sassc.main(['sassc'], 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()
コード例 #6
0
 def test_no_args(self):
     exit_code = sassc.main(['sassc'], 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()
コード例 #7
0
 def test_three_args(self):
     exit_code = sassc.main(['sassc', '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() == ''
コード例 #8
0
 def test_sassc_source_map_without_css_filename(self):
     exit_code = sassc.main(['sassc', '-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() == ''
コード例 #9
0
 def test_sassc_source_map_without_css_filename(self):
     exit_code = sassc.main(['sassc', '-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() == ''
コード例 #10
0
 def test_sassc_stdout(self):
     with pytest.warns(FutureWarning) as warninfo:
         exit_code = sassc.main(
             ['sassc', 'test/a.scss'],
             self.out, self.err,
         )
     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()
コード例 #11
0
 def test_three_args(self):
     exit_code = sassc.main(
         ['sassc', '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() == ''
コード例 #12
0
 def test_sassc_output_unicode(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = sassc.main(['sassc', '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)
コード例 #13
0
ファイル: sasstests.py プロジェクト: uceo/uceo-2015
 def test_sassc_output(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = sassc.main(['sassc', 'test/a.scss', tmp],
                                self.out, self.err)
         self.assertEqual(0, exit_code)
         self.assertEqual('', self.err.getvalue())
         self.assertEqual('', self.out.getvalue())
         with open(tmp) as f:
             self.assertEqual(A_EXPECTED_CSS.strip(), f.read().strip())
     finally:
         os.remove(tmp)
コード例 #14
0
 def test_sassc_output_unicode(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = sassc.main(['sassc', '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)
コード例 #15
0
 def test_sassc_output_unicode(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = sassc.main(['sassc', 'test/d.scss', tmp], self.out,
                                self.err)
         self.assertEqual(0, exit_code)
         self.assertEqual('', self.err.getvalue())
         self.assertEqual('', self.out.getvalue())
         with open(tmp, **utf8_if_py3) as f:
             self.assertEqual(D_EXPECTED_CSS.strip(), f.read().strip())
     finally:
         os.remove(tmp)
コード例 #16
0
 def test_sassc_sourcemap(self):
     with tempdir() as tmp_dir:
         src_dir = os.path.join(tmp_dir, 'test')
         shutil.copytree('test', src_dir)
         src_filename = os.path.join(src_dir, 'a.scss')
         out_filename = os.path.join(tmp_dir, 'a.scss.css')
         exit_code = sassc.main(['sassc', '-m', src_filename, out_filename],
                                self.out, self.err)
         assert exit_code == 0
         assert self.err.getvalue() == ''
         assert self.out.getvalue() == ''
         with open(out_filename) as f:
             assert A_EXPECTED_CSS_WITH_MAP == f.read().strip()
         with open(out_filename + '.map') as f:
             self.assert_source_map_equal(
                 dict(A_EXPECTED_MAP, sources=None),
                 dict(json.load(f), sources=None))
コード例 #17
0
 def test_sassc_sourcemap(self):
     with tempdir() as tmp_dir:
         src_dir = os.path.join(tmp_dir, 'test')
         shutil.copytree('test', src_dir)
         src_filename = os.path.join(src_dir, 'a.scss')
         out_filename = os.path.join(tmp_dir, 'a.scss.css')
         exit_code = sassc.main(
             ['sassc', '-m', src_filename, out_filename],
             self.out, self.err
         )
         assert exit_code == 0
         assert self.err.getvalue() == ''
         assert self.out.getvalue() == ''
         with open(out_filename) as f:
             assert A_EXPECTED_CSS_WITH_MAP == f.read().strip()
         with open(out_filename + '.map') as f:
             self.assert_source_map_equal(
                 dict(A_EXPECTED_MAP, sources=None),
                 dict(json.load(f), sources=None)
             )
コード例 #18
0
ファイル: sasstests.py プロジェクト: uceo/uceo-2015
 def test_sassc_sourcemap(self):
     fd, tmp = tempfile.mkstemp('.css')
     try:
         os.close(fd)
         exit_code = sassc.main(['sassc', '-m', 'test/a.scss', tmp],
                                self.out, self.err)
         self.assertEqual(0, exit_code)
         self.assertEqual('', self.err.getvalue())
         self.assertEqual('', self.out.getvalue())
         with open(tmp) as f:
             self.assertEqual(
                 A_EXPECTED_CSS + '\n/*# sourceMappingURL=' + 
                 os.path.basename(tmp) + '.map */',
                 f.read().strip()
             )
         with open(tmp + '.map') as f:
             self.assertEqual(
                 dict(A_EXPECTED_MAP, sources=None),
                 dict(json.load(f), sources=None)
             )
     finally:
         os.remove(tmp)
コード例 #19
0
 def test_sassc_sourcemap(self):
     tmp_dir = tempfile.mkdtemp()
     src_dir = os.path.join(tmp_dir, 'test')
     shutil.copytree('test', src_dir)
     src_filename = os.path.join(src_dir, 'a.scss')
     out_filename = os.path.join(tmp_dir, 'a.scss.css')
     try:
         exit_code = sassc.main(['sassc', '-m', src_filename, out_filename],
                                self.out, self.err)
         self.assertEqual(0, exit_code)
         self.assertEqual('', self.err.getvalue())
         self.assertEqual('', self.out.getvalue())
         with open(out_filename) as f:
             self.assertEqual(
                 A_EXPECTED_CSS_WITH_MAP.replace(
                     'SOURCE', normalize_path(src_filename)),
                 f.read().strip())
         with open(out_filename + '.map') as f:
             self.assert_source_map_equal(
                 dict(A_EXPECTED_MAP, sources=None),
                 dict(json.load(f), sources=None))
     finally:
         shutil.rmtree(tmp_dir)
コード例 #20
0
 def test_sassc_stdout(self):
     exit_code = sassc.main(['sassc', 'test/a.scss'], self.out, self.err)
     assert exit_code == 0
     assert self.err.getvalue() == ''
     assert A_EXPECTED_CSS.strip() == self.out.getvalue().strip()
コード例 #21
0
ファイル: sasstests.py プロジェクト: uceo/uceo-2015
 def test_sassc_stdout(self):
     exit_code = sassc.main(['sassc', 'test/a.scss'], self.out, self.err)
     self.assertEqual(0, exit_code)
     self.assertEqual('', self.err.getvalue())
     self.assertEqual(A_EXPECTED_CSS.strip(), self.out.getvalue().strip())
コード例 #22
0
 def test_sassc_stdout(self):
     exit_code = sassc.main(['sassc', 'test/a.scss'], self.out, self.err)
     assert exit_code == 0
     assert self.err.getvalue() == ''
     assert A_EXPECTED_CSS.strip() == self.out.getvalue().strip()
コード例 #23
0
 def test_sassc_stdout(self):
     exit_code = sassc.main(['sassc', 'test/a.scss'], self.out, self.err)
     self.assertEqual(0, exit_code)
     self.assertEqual('', self.err.getvalue())
     self.assertEqual(A_EXPECTED_CSS.strip(), self.out.getvalue().strip())