tests: Don't rely on test order.

This commit is contained in:
Dylan Araps 2017-07-23 21:36:58 +10:00
parent 5f6de5efe8
commit 06d993bc06

View File

@ -5,9 +5,7 @@ import io
import pathlib
from pywal import colors
CACHE_DIR = pathlib.Path("/tmp/wal")
from pywal import util
class TestGenColors(unittest.TestCase):
@ -15,7 +13,7 @@ class TestGenColors(unittest.TestCase):
def test_gen_colors(self):
"""> Generate a colorscheme."""
result = colors.get("tests/test_files/test.jpg", CACHE_DIR)
result = colors.get("tests/test_files/test.jpg")
self.assertEqual(len(result["colors"]["color0"]), 7)
def test_gen_colors_fail(self):
@ -25,11 +23,16 @@ class TestGenColors(unittest.TestCase):
def test_color_cache(self):
"""> Test importing a cached scheme."""
# Create the file to import.
cache_dir = pathlib.Path("/tmp/wal2/")
util.save_file("true", cache_dir / "schemes"
/ "tests_test_files_test_jpg.json")
# Since this function just prints a message we redirect
# it's output so that we can read it.
message = "colors: Found cached colorscheme."
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
colors.get("tests/test_files/test.jpg", CACHE_DIR)
colors.get("tests/test_files/test.jpg", cache_dir)
self.assertEqual(fake_out.getvalue().strip(), message)
def test_color_import(self):