diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_export.py | 27 | ||||
| -rw-r--r-- | tests/test_main.py | 3 |
2 files changed, 16 insertions, 14 deletions
diff --git a/tests/test_export.py b/tests/test_export.py index e2838fe..7cb0bb4 100755 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -2,7 +2,7 @@ import unittest import unittest.mock import io -import pathlib +import os from pywal import export from pywal import util @@ -11,7 +11,6 @@ from pywal import util # Import colors. COLORS = util.read_file_json("tests/test_files/test_file.json") COLORS["colors"].update(COLORS["special"]) -OUTPUT_DIR = pathlib.Path("/tmp/wal") util.create_dir("/tmp/wal") @@ -21,25 +20,27 @@ class TestExportColors(unittest.TestCase): def test_all_templates(self): """> Test substitutions in template file.""" - export.every(COLORS, OUTPUT_DIR) + export.every(COLORS, "/tmp/wal") - result = pathlib.Path("/tmp/wal/colors.sh").is_file() + result = os.path.isfile("/tmp/wal/colors.sh") self.assertTrue(result) - content = pathlib.Path("/tmp/wal/colors.sh").read_text() - content = content.split("\n")[6] - self.assertEqual(content, "foreground='#F5F1F4'") + with open("/tmp/wal/colors.sh") as file: + content = file.read().splitlines() + + self.assertEqual(content[6], "foreground='#F5F1F4'") def test_css_template(self): """> Test substitutions in template file (css).""" - export.color(COLORS, "css", OUTPUT_DIR / "test.css") + export.color(COLORS, "css", "/tmp/wal/test.css") - result = pathlib.Path("/tmp/wal/test.css").is_file() + result = os.path.isfile("/tmp/wal/test.css") self.assertTrue(result) - content = pathlib.Path("/tmp/wal/test.css").read_text() - content = content.split("\n")[6] - self.assertEqual(content, " --background: #1F211E;") + with open("/tmp/wal/test.css") as file: + content = file.read().splitlines() + + self.assertEqual(content[6], " --background: #1F211E;") def test_invalid_template(self): """> Test template validation.""" @@ -48,7 +49,7 @@ class TestExportColors(unittest.TestCase): # 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") + export.color(COLORS, "dummy", "/tmp/wal/test.css") self.assertEqual(fake_out.getvalue().strip(), error_msg) diff --git a/tests/test_main.py b/tests/test_main.py index 7f1a1bb..daf9cab 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -16,7 +16,8 @@ class TestMain(unittest.TestCase): """> Test arg parsing (-c)""" args = __main__.get_args(["-c"]) __main__.process_args(args) - self.assertFalse(os.path.isdir(str(CACHE_DIR / "schemes"))) + scheme_dir = os.path.join(CACHE_DIR, "schemes") + self.assertFalse(os.path.isdir(scheme_dir)) def test_args_e(self): """> Test arg parsing (-e)""" |
