tests: Added set_colors tests.

This commit is contained in:
Dylan Araps 2017-06-27 17:24:27 +10:00
parent 081bb9066b
commit 790ab71c50
5 changed files with 41 additions and 2 deletions

View File

@ -35,6 +35,6 @@ setup(
entry_points={ entry_points={
"console_scripts": ["wal=pywal.__main__:main"] "console_scripts": ["wal=pywal.__main__:main"]
}, },
requires_python=">=3.6", python_requires=">=3.6",
test_suite="tests", test_suite="tests",
) )

View File

@ -1,10 +1,15 @@
"""Test util functions.""" """Test util functions."""
import unittest import unittest
import pathlib import pathlib
from pywal import export_colors from pywal import export_colors
from pywal import util from pywal import util
# Import colors.
COLORS = util.read_file("tests/test_file")
class TestExportColors(unittest.TestCase): class TestExportColors(unittest.TestCase):
"""Test the export_colors functions.""" """Test the export_colors functions."""

View File

@ -1,5 +1,6 @@
"""Test format functions.""" """Test format functions."""
import unittest import unittest
from pywal import format_color from pywal import format_color
from pywal import util from pywal import util
@ -8,7 +9,7 @@ from pywal import util
COLORS = util.read_file("tests/test_file") COLORS = util.read_file("tests/test_file")
class TestExportColors(unittest.TestCase): class TestFormatColors(unittest.TestCase):
"""Test the format_colors functions.""" """Test the format_colors functions."""
def test_plain(self): def test_plain(self):

32
tests/test_set_colors.py Executable file
View File

@ -0,0 +1,32 @@
"""Test set functions."""
import unittest
from pywal import set_colors
from pywal import util
# Import colors.
COLORS = util.read_file("tests/test_file")
class TestSetColors(unittest.TestCase):
"""Test the format_colors functions."""
def test_set_special(self):
"""> Create special escape sequence."""
result = set_colors.set_special(11, COLORS[0])
self.assertEqual(result, "\x1b]11;#363442\x07")
def test_set_color(self):
"""> Create color escape sequence."""
result = set_colors.set_color(11, COLORS[0])
self.assertEqual(result, "\033]4;11;#363442\007")
def test_set_grey(self):
"""> Create special escape sequence."""
result = set_colors.set_grey(COLORS)
self.assertEqual(result, "#999999")
if __name__ == "__main__":
unittest.main()

View File

@ -1,6 +1,7 @@
"""Test util functions.""" """Test util functions."""
import unittest import unittest
import pathlib import pathlib
from pywal import util from pywal import util