diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-08-12 18:42:27 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-12 18:42:27 +1000 |
| commit | 8be48c07fff889ed085744cc0cf585b6d0b71a89 (patch) | |
| tree | 839edfa96574721cc6fc82ef18059d75ebef792e /tests/test_export.py | |
| parent | f14aaf5a4fd1847a5316f9c41965daebc23db818 (diff) | |
| parent | c743cab4f0b74e928496c2a5052906da52acc8f7 (diff) | |
Merge pull request #79 from dylanaraps/35
general: Add support for Python 3.5
Diffstat (limited to 'tests/test_export.py')
| -rwxr-xr-x | tests/test_export.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/test_export.py b/tests/test_export.py index 2323c69..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,34 +20,36 @@ 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.""" - error_msg = "[!] warning: template 'dummy' doesn't exist." + 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") + export.color(COLORS, "dummy", "/tmp/wal/test.css") self.assertEqual(fake_out.getvalue().strip(), error_msg) |
