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.

TestQLinearGradientConformer.test_incomplete_coords()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nop 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
    css_float_coords_str = (
95
        'qlineargradient(0, 0.75, 0, 0, (0 green, 1 pink))'
96
    )
97
98
    qss_float_coords_str = (
99
        'qlineargradient(y1:0.75, stop:0 green, stop: 1 pink)'
100
    )
101
102
    def test_does_not_affect_css_form(self):
103
        """QLinearGradientConformer no affect on css qlineargradient func."""
104
105
        c = QLinearGradientConformer()
106
        self.assertEqual(c.to_scss(self.css_str), self.css_str)
107
        self.assertEqual(c.to_qss(self.css_str), self.css_str)
108
109
    def test_conform_singleline_str(self):
110
        """QLinearGradientConformer singleline qss to scss."""
111
112
        c = QLinearGradientConformer()
113
        self.assertEqual(c.to_scss(self.qss_singleline_str), self.css_str)
114
115
    def test_conform_multiline_str(self):
116
        """QLinearGradientConformer multiline qss to scss."""
117
118
        c = QLinearGradientConformer()
119
        self.assertEqual(c.to_scss(self.qss_multiline_str), self.css_str)
120
121
    def test_conform_weird_whitespace_str(self):
122
        """QLinearGradientConformer weird whitespace qss to scss."""
123
124
        c = QLinearGradientConformer()
125
        self.assertEqual(c.to_scss(self.qss_weird_whitespace_str), self.css_str)
126
127
    def test_conform_nostops_str(self):
128
        """QLinearGradientConformer qss with no stops to scss."""
129
130
        c = QLinearGradientConformer()
131
        self.assertEqual(c.to_scss(self.qss_nostops_str), self.css_nostops_str)
132
133
    def test_conform_vars_str(self):
134
        """QLinearGradientConformer qss with vars to scss."""
135
136
        c = QLinearGradientConformer()
137
        self.assertEqual(c.to_scss(self.qss_vars_str), self.css_vars_str)
138
139
    def test_conform_rgba_str(self):
140
        """QLinearGradientConformer qss with rgba to scss."""
141
142
        c = QLinearGradientConformer()
143
        self.assertEqual(c.to_scss(self.qss_rgba_str), self.css_rgba_str)
144
145
    def test_incomplete_coords(self):
146
        """QLinearGradientConformer qss with not all 4 coordinates given."""
147
148
        c = QLinearGradientConformer()
149
        self.assertEqual(c.to_scss(self.qss_incomplete_coords_str),
150
                         self.css_incomplete_coords_str)
151
152
    def test_float_coords(self):
153
        c = QLinearGradientConformer()
154
        self.assertEqual(c.to_scss(self.qss_float_coords_str),
155
                         self.css_float_coords_str)
156
157
158
if __name__ == "__main__":
159
    unittest.main(verbosity=2)
160