Beispiel #1
0
 def test_no_source_maps_override(self):
     """Source maps not produced when environment variable overides compile options"""
     config = dict(entry=self.entry, output=self.output)
     os.environ['SPHINX_SASS_SOURCE_MAPS'] = '0'
     app = self.get_sphinx_app()
     compile_sass_config(app, config)
     _, css = parse_css(self.output, raw=True)
     self.assertNotIn('sourceMappingURL', css)
     del os.environ['SPHINX_SASS_SOURCE_MAPS']
Beispiel #2
0
 def test_external_source_maps_config(self):
     """Check external source maps produced using config option"""
     config = dict(entry=self.entry, output=self.output, source_map='file')
     app = self.get_sphinx_app()
     compile_sass_config(app, config)
     _, css = parse_css(self.output, raw=True)
     self.assertIn('sourceMappingURL', css)
     self.assertTrue(
         os.path.exists(
             os.path.join(os.path.dirname(self.output), 'main.css.map')))
Beispiel #3
0
    def test_embedded_source_map_config(self):
        """Check embeded source map produced using config option"""
        config = dict(entry=self.entry, output=self.output, source_map='embed')

        app = self.get_sphinx_app()
        compile_sass_config(app, config)
        rules, css = parse_css(self.output, raw=True)
        self.assertIn('sourceMappingURL', css)
        self.assertEqual(len(rules), 2)
        for selector in self.selectors:
            self.assertIn(selector, rules)
            self.assertDictEqual(rules[selector], {'color': 'red'})
Beispiel #4
0
    def test_no_source_map(self):
        """Check defaults do not produce source map."""
        config = dict(entry=self.entry, output=self.output)

        app = self.get_sphinx_app()
        compile_sass_config(app, config)
        rules, css = parse_css(self.output, raw=True)
        self.assertNotIn('sourceMappingURL', css)
        self.assertEqual(len(rules), 2)
        for selector in self.selectors:
            self.assertIn(selector, rules)
            self.assertDictEqual(rules[selector], {'color': 'red'})
Beispiel #5
0
    def test_external_source_maps_different_path(self):
        """Check external source maps produced with different path"""

        source_map_filename = os.path.join('maps', 'main.css.map')
        config = dict(
            entry=self.entry,
            output=self.output,
            compile_options=dict(source_map_filename=source_map_filename))
        app = self.get_sphinx_app()
        compile_sass_config(app, config)

        _, css = parse_css(self.output, raw=True)
        self.assertIn('sourceMappingURL', css)

        srcmap_url = get_source_mapping_url(css)
        self.assertEqual(srcmap_url, source_map_filename)

        self.assertTrue(
            os.path.exists(
                os.path.join(os.path.dirname(self.output),
                             source_map_filename)))
Beispiel #6
0
    def test_relative_entry_path(self):
        """Test relative entry path."""

        entry = os.path.basename(self.entry)
        with chdir(os.path.dirname(self.entry)):
            self.create_file(
                entry,
                contents=
                '$color: red !default; .document { h1, h2 { color: $color; } }'
            )

        config = dict(entry=entry, output=self.output)

        app = self.get_sphinx_app()
        compile_sass_config(app, config)
        self.assertTrue(os.path.exists(self.output))
        rules, css = parse_css(self.output, raw=True)
        self.assertNotIn('sourceMappingURL', css)
        self.assertEqual(len(rules), 2)
        for selector in self.selectors:
            self.assertIn(selector, rules)
            self.assertDictEqual(rules[selector], {'color': 'red'})