tests: Remove shitty tests

This commit is contained in:
Dylan Araps 2017-07-24 00:00:35 +10:00
parent b678a60a23
commit 7ebc29ff34
4 changed files with 1 additions and 112 deletions

View File

@ -1,11 +1,7 @@
"""Test imagemagick functions."""
import unittest
import unittest.mock
import io
import pathlib
from pywal import colors
from pywal import util
class TestGenColors(unittest.TestCase):
@ -21,20 +17,6 @@ class TestGenColors(unittest.TestCase):
with self.assertRaises(SystemExit):
colors.get("tests/test_files/test.png")
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)
self.assertEqual(fake_out.getvalue().strip(), message)
def test_color_import(self):
"""> Read colors from a file."""
result = colors.file("tests/test_files/test_file.json")

View File

@ -1,6 +1,5 @@
"""Test __main__ functions."""
import unittest
import os
from pywal import __main__
from pywal.settings import __cache_dir__
@ -9,70 +8,11 @@ from pywal.settings import __cache_dir__
class TestMain(unittest.TestCase):
"""Test the gen_colors functions."""
def test_main(self):
"""> Test main function."""
with self.assertRaises(SystemExit):
__main__.main()
def test_no_args(self):
"""> Test no args."""
with self.assertRaises(SystemExit):
args = __main__.get_args([""])
__main__.process_args(args)
def test_conflict(self):
"""> Test arg parsing (-i, -f)"""
with self.assertRaises(SystemExit):
args = __main__.get_args(["-i", "file", "-f", "file"])
__main__.process_args(args)
def test_version(self):
"""> Test arg parsing (-v)"""
with self.assertRaises(SystemExit):
args = __main__.get_args(["-v"])
__main__.process_args(args)
def test_quiet(self):
"""> Test arg parsing (-q)"""
args = __main__.get_args(["-q"])
__main__.process_args(args)
self.assertTrue(args.q)
def test_alpha(self):
"""> Test arg parsing (-a)"""
args = __main__.get_args(["-a", "99"])
__main__.process_args(args)
self.assertTrue(args.a)
def test_ext_script(self):
"""> Test arg parsing (-o)"""
args = __main__.get_args(["-o", "true"])
__main__.process_args(args)
self.assertTrue(args.o)
def test_clean(self):
"""> Test arg parsing (-c)"""
args = __main__.get_args(["-c"])
__main__.process_args(args)
self.assertFalse(os.path.isdir(__cache_dir__ / "schemes"))
def test_reload(self):
"""> Test arg parsing (-r)"""
with self.assertRaises(SystemExit):
args = __main__.get_args(["-r"])
__main__.process_args(args)
def test_image(self):
"""> Test arg parsing (-i)"""
args = __main__.get_args(["-i", "tests/test_files/test.jpg"])
__main__.process_args(args)
self.assertTrue(args.i)
def test_json(self):
"""> Test arg parsing (-f)"""
args = __main__.get_args(["-f", "tests/test_files/test_file.json"])
__main__.process_args(args)
self.assertTrue(args.f)
self.assertFalse((__cache_dir__ / "schemes").is_dir())
if __name__ == "__main__":

View File

@ -1,7 +1,5 @@
"""Test sequence functions."""
import unittest
import unittest.mock
import io
from pywal import sequences
from pywal import util
@ -31,13 +29,6 @@ class Testsequences(unittest.TestCase):
result = sequences.set_color(11, COLORS["colors"]["color0"])
self.assertEqual(result, "\033]4;11;#1F211E\007")
def test_send_sequences(self):
"""> Send sequences to all open terminals."""
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
sequences.send(COLORS, False)
data = fake_out.getvalue().strip()
self.assertTrue(data.endswith("colors: Set terminal colors"))
if __name__ == "__main__":
unittest.main()

View File

@ -1,10 +1,7 @@
"""Test util functions."""
import unittest
import unittest.mock
import io
import os
import pathlib
import time
from pywal import util
@ -84,27 +81,6 @@ class TestUtil(unittest.TestCase):
result = util.hex_to_xrgba("#98AEC2")
self.assertEqual(result, "98/ae/c2/ff")
def test_disown(self):
"""> Test disown command."""
test_file = pathlib.Path("/tmp/wal-test-disown")
util.disown("touch", test_file)
# We won't know when 'disown' will finish so we
# sleep here.
time.sleep(10)
result = test_file.is_file()
self.assertTrue(result)
os.remove(test_file)
def test_msg(self):
"""> Test displaying a message."""
# Since this function just prints a message we redirect
# it's output so that we can read it.
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
util.msg("test", True)
self.assertEqual(fake_out.getvalue().strip(), "test")
if __name__ == "__main__":
unittest.main()