diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 20:53:33 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-23 20:53:33 +1000 |
| commit | f8d02a1307ab570a8542ef9755ee548026f0f6ea (patch) | |
| tree | 6aa0389de2aa5412bcda4ca5bfba963f61f9f329 /tests/test_export.py | |
| parent | a745c856c1d764d87e2491b7151829f2c494ecda (diff) | |
tests: Added test for template fail
Diffstat (limited to 'tests/test_export.py')
| -rwxr-xr-x | tests/test_export.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_export.py b/tests/test_export.py index ebf5740..2323c69 100755 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -1,5 +1,7 @@ """Test export functions.""" import unittest +import unittest.mock +import io import pathlib from pywal import export @@ -39,6 +41,16 @@ class TestExportColors(unittest.TestCase): content = content.split("\n")[6] 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__": unittest.main() |
