加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_util.py 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
LLL 提交于 2022-06-27 15:20 . Import Upstream version 7.0.0
import unittest
from PIL import _util
from .helper import PillowTestCase
class TestUtil(PillowTestCase):
def test_is_path(self):
# Arrange
fp = "filename.ext"
# Act
it_is = _util.isPath(fp)
# Assert
self.assertTrue(it_is)
@unittest.skipUnless(_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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化