代码拉取完成,页面将自动刷新
同步操作将从 openKylin/pillow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import unittest
from PIL import Image, TarIO
from .helper import PillowTestCase, is_pypy
codecs = dir(Image.core)
# Sample tar archive
TEST_TAR_FILE = "Tests/images/hopper.tar"
class TestFileTar(PillowTestCase):
def setUp(self):
if "zip_decoder" not in codecs and "jpeg_decoder" not in codecs:
self.skipTest("neither jpeg nor zip support available")
def test_sanity(self):
for codec, test_path, format in [
["zip_decoder", "hopper.png", "PNG"],
["jpeg_decoder", "hopper.jpg", "JPEG"],
]:
if codec in codecs:
with TarIO.TarIO(TEST_TAR_FILE, test_path) as tar:
with Image.open(tar) as im:
im.load()
self.assertEqual(im.mode, "RGB")
self.assertEqual(im.size, (128, 128))
self.assertEqual(im.format, format)
@unittest.skipIf(is_pypy(), "Requires CPython")
def test_unclosed_file(self):
def open():
TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg")
self.assert_warning(ResourceWarning, open)
def test_close(self):
def open():
tar = TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg")
tar.close()
self.assert_warning(None, open)
def test_contextmanager(self):
def open():
with TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg"):
pass
self.assert_warning(None, open)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。