tests: Fix comments

This commit is contained in:
Dylan Araps 2017-06-27 17:02:42 +10:00
parent ce2d85d5d6
commit 10c7099a27
3 changed files with 29 additions and 8 deletions

View File

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

21
tests/test_export_colors.py Executable file
View File

@ -0,0 +1,21 @@
"""Test util functions."""
import unittest
import pathlib
from pywal import export_colors
from pywal import util
class TestExportColors(unittest.TestCase):
"""Test the export_colors functions."""
def test_save_colors(self):
"""> Export colors to a file."""
tmp_file = pathlib.Path("/tmp/test_file")
colors = util.read_file("tests/test_file")
export_colors.save_colors(colors, tmp_file, "plain colors")
result = tmp_file.is_file()
self.assertTrue(result)
if __name__ == "__main__":
unittest.main()

View File

@ -8,41 +8,41 @@ class TestUtil(unittest.TestCase):
"""Test the util functions.""" """Test the util functions."""
def test_read_file_start(self): def test_read_file_start(self):
"""Test read_file().""" """> Read colors from a file."""
result = util.read_file("tests/test_file") result = util.read_file("tests/test_file")
self.assertEqual(result[0], "#363442") self.assertEqual(result[0], "#363442")
def test_read_file_end(self): def test_read_file_end(self):
"""Test read_file().""" """> Read colors from a file."""
result = util.read_file("tests/test_file") result = util.read_file("tests/test_file")
self.assertEqual(result[15], "#C9CFD0") self.assertEqual(result[15], "#C9CFD0")
def test_save_file(self): def test_save_file(self):
"""Test save_file().""" """> Save colors to a file."""
tmp_file = pathlib.Path("/tmp/test_file") tmp_file = pathlib.Path("/tmp/test_file")
util.save_file("Hello, world", tmp_file) util.save_file("Hello, world", tmp_file)
result = tmp_file.is_file() result = tmp_file.is_file()
self.assertTrue(result) self.assertTrue(result)
def test_create_dir(self): def test_create_dir(self):
"""Test create_dir().""" """> Create a directoru."""
tmp_dir = pathlib.Path("/tmp/test_dir") tmp_dir = pathlib.Path("/tmp/test_dir")
util.create_dir(tmp_dir) util.create_dir(tmp_dir)
result = tmp_dir.is_dir() result = tmp_dir.is_dir()
self.assertTrue(result) self.assertTrue(result)
def test_hex_to_rgb_black(self): def test_hex_to_rgb_black(self):
"""Test hex_to_rgb() on #000000.""" """> Convert #000000 to RGB."""
result = util.hex_to_rgb("#000000") result = util.hex_to_rgb("#000000")
self.assertEqual(result, "0,0,0") self.assertEqual(result, "0,0,0")
def test_hex_to_rgb_white(self): def test_hex_to_rgb_white(self):
"""Test hex_to_rgb() on #FFFFFF.""" """> Convert #FFFFFF to RGB."""
result = util.hex_to_rgb("#FFFFFF") result = util.hex_to_rgb("#FFFFFF")
self.assertEqual(result, "255,255,255") self.assertEqual(result, "255,255,255")
def test_hex_to_rgb_rand(self): def test_hex_to_rgb_rand(self):
"""Test hex_to_rgb() on #98AEC2.""" """> Convert #98AEC2 to RGB."""
result = util.hex_to_rgb("#98AEC2") result = util.hex_to_rgb("#98AEC2")
self.assertEqual(result, "152,174,194") self.assertEqual(result, "152,174,194")