GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#27)
by
unknown
01:14
created

tests.test_api.test_compile_import_raises()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nop 0
1
# -*- coding: utf-8 -*-
2
# -----------------------------------------------------------------------------
3
# Copyright (c) 2015 Yann Lanthony
4
# Copyright (c) 2017-2018 Spyder Project Contributors
5
#
6
# Licensed under the terms of the MIT License
7
# (See LICENSE.txt for details)
8
# -----------------------------------------------------------------------------
9
"""Test qtsass api."""
10
11
# Standard library imports
12
from __future__ import absolute_import
13
from os.path import exists
14
15
# Third party imports
16
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
17
import sass
18
19
# Local imports
20
from . import PROJECT_DIR, EXAMPLES_DIR, example
0 ignored issues
show
Unused Code introduced by
The import PROJECT_DIR seems to be unused.
Loading history...
21
import qtsass
0 ignored issues
show
introduced by
external import "import qtsass" should be placed before "from . import PROJECT_DIR, EXAMPLES_DIR, example"
Loading history...
22
23
24
COLORS_STR = """
25
QWidget {
26
    background: rgba(127, 127, 127, 100%);
27
    color: rgb(255, 255, 255);
28
}
29
"""
30
QLINEARGRADIENTS_STR = """
31
QWidget {
32
    background: qlineargradient(
33
        x1: 0,
34
        y1: 0,
35
        x2: 0,
36
        y2: 1,
37
        stop: 0.1 blue,
38
        stop: 0.8 green
39
    );
40
}
41
"""
42
QNOT_STR = """
43
QLineEdit:!editable {
44
    background: white;
45
}
46
"""
47
IMPORT_STR = """
48
@import 'dummy';
49
"""
50
CUSTOM_BORDER_STR = """
51
QWidget {
52
    border: custom_border();
53
}
54
"""
55
56
57
def test_compile_strings():
58
    """compile various strings."""
59
60
    qtsass.compile(COLORS_STR)
61
    qtsass.compile(QLINEARGRADIENTS_STR)
62
    qtsass.compile(QNOT_STR)
63
64
65
def test_compile_import_raises():
66
    """compile string with import raises."""
67
68
    with pytest.raises(sass.CompileError):
69
        qtsass.compile(IMPORT_STR)
70
71
72
def test_compile_import_with_include_paths():
0 ignored issues
show
Coding Style Naming introduced by
The name test_compile_import_with_include_paths does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
73
    """compile string with include_paths"""
74
75
    qtsass.compile(IMPORT_STR, include_paths=[EXAMPLES_DIR])
76
77
78
def test_compile_custom_function():
79
    """compile string with custom_functions"""
80
81
    custom_str = (
82
        'QWidget {\n'
83
        '    border: custom_border();\n'
84
        '}'
85
    )
86
87
    def custom_border():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
88
        return '1px solid'
89
90
    css = qtsass.compile(custom_str, custom_functions=[custom_border])
91
    assert '1px solid' in css
92
    assert 'custom_border()' not in css
93
94
95
def test_compile_filename(tmpdir):
96
    """compile_filename simple."""
97
98
    output = tmpdir.join('dummy.css')
99
    qtsass.compile_filename(example('dummy.scss'), output.strpath)
100
    assert exists(output.strpath)
101
102
103
def test_compile_filename_imports(tmpdir):
104
    """compile_filename with imports."""
105
106
    output = tmpdir.join('dark.css')
107
    qtsass.compile_filename(example('complex', 'dark.scss'), output.strpath)
108
    assert exists(output.strpath)
109
110
111
def test_compile_dirname(tmpdir):
112
    """compile_dirname complex."""
113
114
    output = tmpdir.join('complex')
115
    qtsass.compile_dirname(example('complex'), output.strpath)
116
    assert exists(output.join('dark.css').strpath)
117
    assert exists(output.join('light.css').strpath)
118