Esempio n. 1
0
def test_compile_raises_ValueError():
    """compile raises ValueError with invalid arguments"""

    # Pass invalid type to importers - must be sequence
    with pytest.raises(ValueError):
        qtsass.compile(COLORS_STR, importers=lambda x: None)

    # Pass invalid type to custom_functions
    with pytest.raises(ValueError):
        qtsass.compile(COLORS_STR, custom_functions=lambda x: None)
Esempio n. 2
0
def test_compile_custom_function():
    """compile string with custom_functions"""

    custom_str = ('QWidget {\n' '    border: custom_border();\n' '}')

    def custom_border():
        return '1px solid'

    css = qtsass.compile(custom_str, custom_functions=[custom_border])
    assert '1px solid' in css
    assert 'custom_border()' not in css
Esempio n. 3
0
def default_stylesheet() -> str:
    with open(str(autodidaqt_LIB_ROOT / "resources" /
                  "default_styles.scss")) as f:
        styles = f.read()

    with open(os.devnull, "w") as devnull:
        with contextlib.redirect_stdout(devnull):
            import qtsass  # <- why is this printing on import?

            compiled = qtsass.compile(
                styles, include_paths=[str(autodidaqt_LIB_ROOT / "resources")])

    return compiled
Esempio n. 4
0
def test_compile_import_with_include_paths():
    """compile string with include_paths"""

    qtsass.compile(IMPORT_STR, include_paths=[EXAMPLES_DIR])
Esempio n. 5
0
def test_compile_import_raises():
    """compile string with import raises."""

    with pytest.raises(sass.CompileError):
        qtsass.compile(IMPORT_STR)
Esempio n. 6
0
def test_compile_strings():
    """compile various strings."""

    qtsass.compile(COLORS_STR)
    qtsass.compile(QLINEARGRADIENTS_STR)
    qtsass.compile(QNOT_STR)