From 691671624c10cd23a3b48a2942998e80cae2c34e Mon Sep 17 00:00:00 2001 From: hugovk Date: Sun, 6 Jul 2014 01:47:30 +0300 Subject: [PATCH] Test _util.py --- Tests/test_util.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Tests/test_util.py diff --git a/Tests/test_util.py b/Tests/test_util.py new file mode 100644 index 000000000..8cf73f47f --- /dev/null +++ b/Tests/test_util.py @@ -0,0 +1,80 @@ +from helper import unittest, PillowTestCase, tearDownModule + +from PIL import _util + + +class TestUtil(PillowTestCase): + + def test_is_string_type(self): + # Arrange + text = "abc" + + # Act + it_is = _util.isStringType(text) + + # Assert + self.assertTrue(it_is) + + def test_is_not_string_type(self): + # Arrange + integer = 123 + + # Act + it_is_not = _util.isStringType(integer) + + # Assert + self.assertFalse(it_is_not) + + def test_is_path(self): + # Arrange + text = "abc" + + # Act + it_is = _util.isStringType(text) + + # Assert + self.assertTrue(it_is) + + def test_is_not_path(self): + # Arrange + integer = 123 + + # Act + it_is_not = _util.isPath(integer) + + # Assert + self.assertFalse(it_is_not) + + def test_is_directory(self): + # Arrange + directory = "Tests" + + # Act + it_is = _util.isDirectory(directory) + + # Assert + self.assertTrue(it_is) + + def test_is_not_directory(self): + # Arrange + text = "abc" + + # Act + it_is_not = _util.isDirectory(text) + + # Assert + self.assertFalse(it_is_not) + + def test_deferred_error(self): + # Arrange + + # Act + thing = _util.deferred_error(ValueError("Some error text")) + + # Assert + self.assertRaises(ValueError, lambda: thing.some_attr) + +if __name__ == '__main__': + unittest.main() + +# End of file