mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-05-30 22:47:14 +02:00
tests: Added test for template fail
This commit is contained in:
parent
a745c856c1
commit
f8d02a1307
@ -1,5 +1,7 @@
|
|||||||
"""Test export functions."""
|
"""Test export functions."""
|
||||||
import unittest
|
import unittest
|
||||||
|
import unittest.mock
|
||||||
|
import io
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from pywal import export
|
from pywal import export
|
||||||
@ -39,6 +41,16 @@ class TestExportColors(unittest.TestCase):
|
|||||||
content = content.split("\n")[6]
|
content = content.split("\n")[6]
|
||||||
self.assertEqual(content, " --background: #1F211E;")
|
self.assertEqual(content, " --background: #1F211E;")
|
||||||
|
|
||||||
|
def test_invalid_template(self):
|
||||||
|
"""> Test template validation."""
|
||||||
|
error_msg = "[!] warning: template 'dummy' doesn't exist."
|
||||||
|
|
||||||
|
# Since this function prints a message on fail we redirect
|
||||||
|
# it's output so that we can read it.
|
||||||
|
with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out:
|
||||||
|
export.color(COLORS, "dummy", OUTPUT_DIR / "test.css")
|
||||||
|
self.assertEqual(fake_out.getvalue().strip(), error_msg)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user