aboutsummaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 4c122e0..903d8b3 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,9 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+import os
+import tempfile
import unittest
from paper2remarkable.exceptions import NoPDFToolError
+
+from paper2remarkable.utils import chdir
from paper2remarkable.utils import check_pdftool
@@ -16,6 +20,24 @@ class TestUtils(unittest.TestCase):
with self.assertRaises(NoPDFToolError):
check_pdftool("pdftk_xyz", "qpdf_xyz")
+ def test_chdir_1(self):
+ start_dir = os.getcwd()
+ tmpdir1 = tempfile.mkdtemp(prefix="p2r_test_chdir_")
+ with chdir(tmpdir1):
+ pwd = os.getcwd()
+ self.assertEqual(pwd, tmpdir1)
+ self.assertEqual(start_dir, os.getcwd())
+
+ def test_chdir_2(self):
+ start_dir = os.getcwd()
+ tmpdir1 = tempfile.mkdtemp(prefix="p2r_test_chdir_")
+ with self.assertRaises(ValueError):
+ with chdir(tmpdir1):
+ pwd = os.getcwd()
+ raise ValueError
+ self.assertEqual(pwd, tmpdir1)
+ self.assertEqual(start_dir, os.getcwd())
+
if __name__ == "__main__":
unittest.main()