Pillow/Tests/test_util.py
Jon Dufresne 4de5477b61 Remove unnecessary unittest.main() boilerplate from test files
With the introduction and use of pytest, it is simple and easy to
execute specific tests in isolation through documented command line
arguments. Either by specifying the module path or through the `-k
EXPRESSION` argument. There is no longer any need to provide the
boilerplate:

    if __name__ == '__main__':
        unittest.main()

To every test file. It is simply noise.

The pattern remains in test files that aren't named with `test_*` as
those files are not discovered and executed by pytest by default.
2019-02-03 10:10:16 -08:00

77 lines
1.5 KiB
Python

from .helper import PillowTestCase
from PIL import _util
class TestUtil(PillowTestCase):
def test_is_string_type(self):
# Arrange
color = "red"
# Act
it_is = _util.isStringType(color)
# Assert
self.assertTrue(it_is)
def test_is_not_string_type(self):
# Arrange
color = (255, 0, 0)
# Act
it_is_not = _util.isStringType(color)
# Assert
self.assertFalse(it_is_not)
def test_is_path(self):
# Arrange
fp = "filename.ext"
# Act
it_is = _util.isPath(fp)
# Assert
self.assertTrue(it_is)
def test_is_not_path(self):
# Arrange
filename = self.tempfile("temp.ext")
fp = open(filename, 'w').close()
# Act
it_is_not = _util.isPath(fp)
# 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)