|
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
|
|
|
# Standard library imports |
|
12
|
|
|
from __future__ import absolute_import |
|
13
|
|
|
import unittest |
|
14
|
|
|
from textwrap import dedent |
|
15
|
|
|
import sass |
|
16
|
|
|
|
|
17
|
|
|
# Local imports |
|
18
|
|
|
from qtsass.api import compile |
|
19
|
|
|
|
|
20
|
|
|
class BaseCompileTest(unittest.TestCase): |
|
21
|
|
|
def compile_scss(self, str): |
|
22
|
|
|
# NOTE: revise for better future compatibility |
|
23
|
|
|
wstr = '*{{t: {0};}}'.format(str) |
|
24
|
|
|
res = compile(wstr) |
|
25
|
|
|
return res.replace('* {\n t: ', '').replace('; }\n', '') |
|
26
|
|
|
|
|
27
|
|
|
class TestRgbaFunc(BaseCompileTest): |
|
28
|
|
|
def test_rgba(self): |
|
29
|
|
|
self.assertEqual( |
|
30
|
|
|
self.compile_scss('rgba(0, 1, 2, 0.3)'), |
|
31
|
|
|
'rgba(0, 1, 2, 30%)' |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
|
|
class TestQLinearGradientFunc(BaseCompileTest): |
|
35
|
|
|
def test_color(self): |
|
36
|
|
|
self.assertEqual( |
|
37
|
|
|
self.compile_scss('qlineargradient(1, 2, 3, 4, (0 red, 1 blue))'), |
|
38
|
|
|
'qlineargradient(x1: 1.0, y1: 2.0, x2: 3.0, y2: 4.0, ' |
|
39
|
|
|
'stop: 0.0 rgba(255, 0, 0, 100%), stop: 1.0 rgba(0, 0, 255, 100%))' |
|
40
|
|
|
) |
|
41
|
|
|
|
|
42
|
|
|
def test_rgba(self): |
|
43
|
|
|
self.assertEqual( |
|
44
|
|
|
self.compile_scss('qlineargradient(1, 2, 3, 4, (0 red, 0.2 rgba(5, 6, 7, 0.8)))'), |
|
45
|
|
|
'qlineargradient(x1: 1.0, y1: 2.0, x2: 3.0, y2: 4.0, ' |
|
46
|
|
|
'stop: 0.0 rgba(255, 0, 0, 100%), stop: 0.2 rgba(5, 6, 7, 80%))' |
|
47
|
|
|
) |
|
48
|
|
|
|