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.
Passed
Pull Request — master (#40)
by
unknown
01:12
created

tests.test_conformers   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 147
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 67
dl 0
loc 147
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A TestNotConformer.test_round_trip() 0 6 1
A TestNotConformer.test_conform_to_qss() 0 5 1
A TestNotConformer.test_conform_to_scss() 0 5 1
A TestQLinearGradientConformer.test_conform_singleline_str() 0 5 1
A TestQLinearGradientConformer.test_conform_rgba_str() 0 5 1
A TestQLinearGradientConformer.test_conform_multiline_str() 0 5 1
A TestQLinearGradientConformer.test_conform_nostops_str() 0 5 1
A TestQLinearGradientConformer.test_incomplete_coords() 0 6 1
A TestQLinearGradientConformer.test_does_not_affect_css_form() 0 6 1
A TestQLinearGradientConformer.test_conform_vars_str() 0 5 1
A TestQLinearGradientConformer.test_conform_weird_whitespace_str() 0 5 1
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 conformers."""
10
11
from __future__ import absolute_import
12
13
# Standard library imports
14
from textwrap import dedent
15
import unittest
16
17
# Local imports
18
from qtsass.conformers import NotConformer, QLinearGradientConformer
19
20
21
class TestNotConformer(unittest.TestCase):
22
23
    qss_str = 'QAbstractItemView::item:!active'
24
    css_str = 'QAbstractItemView::item:_qnot_active'
25
26
    def test_conform_to_scss(self):
27
        """NotConformer qss to scss."""
28
29
        c = NotConformer()
30
        self.assertEqual(c.to_scss(self.qss_str), self.css_str)
31
32
    def test_conform_to_qss(self):
33
        """NotConformer css to qss."""
34
35
        c = NotConformer()
36
        self.assertEqual(c.to_qss(self.css_str), self.qss_str)
37
38
    def test_round_trip(self):
39
        """NotConformer roundtrip."""
40
41
        c = NotConformer()
42
        conformed_css = c.to_scss(self.qss_str)
43
        self.assertEqual(c.to_qss(conformed_css), self.qss_str)
44
45
46
class TestQLinearGradientConformer(unittest.TestCase):
47
48
    css_vars_str = 'qlineargradient($x1, $y1, $x2, $y2, (0 $red, 1 $blue))'
49
    qss_vars_str = (
50
        'qlineargradient(x1:$x1, x2:$x2, y1:$y1, y2:$y2'
51
        'stop: 0 $red, stop: 1 $blue)'
52
    )
53
54
    css_nostops_str = 'qlineargradient(0, 0, 0, 0)'
55
    qss_nostops_str = 'qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0)'
56
57
    css_str = 'qlineargradient(0, 0, 0, 0, (0 red, 1 blue))'
58
    qss_singleline_str = (
59
        'qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0, '
60
        'stop: 0 red, stop: 1 blue)'
61
    )
62
    qss_multiline_str = dedent("""
63
    qlineargradient(
64
        x1: 0,
65
        y1: 0,
66
        x2: 0,
67
        y2: 0,
68
        stop: 0 red,
69
        stop: 1 blue
70
    )
71
    """).strip()
72
    qss_weird_whitespace_str = (
73
        'qlineargradient( x1: 0, y1:0, x2: 0, y2:0, '
74
        '   stop:0 red, stop: 1 blue )'
75
    )
76
77
    css_rgba_str = (
78
        'qlineargradient(0, 0, 0, 0, '
79
        '(0 rgba(0, 1, 2, 30%), 0.99 rgba(7, 8, 9, 100%)))'
80
    )
81
    qss_rgba_str = (
82
        'qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0, '
83
        'stop: 0 rgba(0, 1, 2, 30%), stop: 0.99 rgba(7, 8, 9, 100%))'
84
    )
85
86
    css_incomplete_coords_str = (
87
        'qlineargradient(0, 1, 0, 0, (0 red, 1 blue))'
88
    )
89
90
    qss_incomplete_coords_str = (
91
        'qlineargradient(y1:1, stop:0 red, stop: 1 blue)'
92
    )
93
94
    def test_does_not_affect_css_form(self):
95
        """QLinearGradientConformer no affect on css qlineargradient func."""
96
97
        c = QLinearGradientConformer()
98
        self.assertEqual(c.to_scss(self.css_str), self.css_str)
99
        self.assertEqual(c.to_qss(self.css_str), self.css_str)
100
101
    def test_conform_singleline_str(self):
102
        """QLinearGradientConformer singleline qss to scss."""
103
104
        c = QLinearGradientConformer()
105
        self.assertEqual(c.to_scss(self.qss_singleline_str), self.css_str)
106
107
    def test_conform_multiline_str(self):
108
        """QLinearGradientConformer multiline qss to scss."""
109
110
        c = QLinearGradientConformer()
111
        self.assertEqual(c.to_scss(self.qss_multiline_str), self.css_str)
112
113
    def test_conform_weird_whitespace_str(self):
114
        """QLinearGradientConformer weird whitespace qss to scss."""
115
116
        c = QLinearGradientConformer()
117
        self.assertEqual(c.to_scss(self.qss_weird_whitespace_str), self.css_str)
118
119
    def test_conform_nostops_str(self):
120
        """QLinearGradientConformer qss with no stops to scss."""
121
122
        c = QLinearGradientConformer()
123
        self.assertEqual(c.to_scss(self.qss_nostops_str), self.css_nostops_str)
124
125
    def test_conform_vars_str(self):
126
        """QLinearGradientConformer qss with vars to scss."""
127
128
        c = QLinearGradientConformer()
129
        self.assertEqual(c.to_scss(self.qss_vars_str), self.css_vars_str)
130
131
    def test_conform_rgba_str(self):
132
        """QLinearGradientConformer qss with rgba to scss."""
133
134
        c = QLinearGradientConformer()
135
        self.assertEqual(c.to_scss(self.qss_rgba_str), self.css_rgba_str)
136
137
    def test_incomplete_coords(self):
138
        """QLinearGradientConformer qss with not all 4 coordinates given."""
139
140
        c = QLinearGradientConformer()
141
        self.assertEqual(c.to_scss(self.qss_incomplete_coords_str),
142
                         self.css_incomplete_coords_str)
143
144
145
if __name__ == "__main__":
146
    unittest.main(verbosity=2)
147