tests: Fix errors

This commit is contained in:
Dylan Araps 2017-07-23 21:29:38 +10:00
parent e8475c05ea
commit 5f6de5efe8
2 changed files with 7 additions and 3 deletions

View File

@ -2,16 +2,20 @@
import unittest import unittest
import unittest.mock import unittest.mock
import io import io
import pathlib
from pywal import colors from pywal import colors
CACHE_DIR = pathlib.Path("/tmp/wal")
class TestGenColors(unittest.TestCase): class TestGenColors(unittest.TestCase):
"""Test the gen_colors functions.""" """Test the gen_colors functions."""
def test_gen_colors(self): def test_gen_colors(self):
"""> Generate a colorscheme.""" """> Generate a colorscheme."""
result = colors.get("tests/test_files/test.jpg") result = colors.get("tests/test_files/test.jpg", CACHE_DIR)
self.assertEqual(len(result["colors"]["color0"]), 7) self.assertEqual(len(result["colors"]["color0"]), 7)
def test_gen_colors_fail(self): def test_gen_colors_fail(self):
@ -25,7 +29,7 @@ class TestGenColors(unittest.TestCase):
# it's output so that we can read it. # it's output so that we can read it.
message = "colors: Found cached colorscheme." message = "colors: Found cached colorscheme."
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out: with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
colors.get("tests/test_files/test.jpg") colors.get("tests/test_files/test.jpg", CACHE_DIR)
self.assertEqual(fake_out.getvalue().strip(), message) self.assertEqual(fake_out.getvalue().strip(), message)
def test_color_import(self): def test_color_import(self):

View File

@ -14,7 +14,7 @@ class TestImage(unittest.TestCase):
def test_get_img_dir(self): def test_get_img_dir(self):
"""> Validate image directory.""" """> Validate image directory."""
result = image.get("tests/test_files") result = image.get("tests/test_files")
self.assertEqual(result.endswith(".jpg"), True) self.assertEqual(result.endswith((".jpg", ".png")), True)
def test_get_img_fail(self): def test_get_img_fail(self):
"""> Validate image file. (fail)""" """> Validate image file. (fail)"""