mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
d50445ff30
Similar to the recent adoption of Black. isort is a Python utility to sort imports alphabetically and automatically separate into sections. By using isort, contributors can quickly and automatically conform to the projects style without thinking. Just let the tool do it. Uses the configuration recommended by the Black to avoid conflicts of style. Rewrite TestImageQt.test_deprecated to no rely on import order.
89 lines
1.8 KiB
Python
89 lines
1.8 KiB
Python
from PIL import _util
|
|
|
|
from .helper import PillowTestCase, unittest
|
|
|
|
|
|
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)
|
|
|
|
@unittest.skipIf(not _util.py36, "os.path support for Paths added in 3.6")
|
|
def test_path_obj_is_path(self):
|
|
# Arrange
|
|
from pathlib import Path
|
|
|
|
test_path = Path("filename.ext")
|
|
|
|
# Act
|
|
it_is = _util.isPath(test_path)
|
|
|
|
# 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)
|