Merge pull request #3631 from jdufresne/test-main

Remove unnecessary unittest.main() boilerplate from test files
This commit is contained in:
Hugo 2019-02-12 18:12:29 +02:00 committed by GitHub
commit dc3c64a0e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
147 changed files with 123 additions and 718 deletions

View File

@ -13,28 +13,20 @@ Install::
Execution
---------
**If Pillow has been built in-place**
To run an individual test::
python Tests/test_image.py
pytest Tests/test_image.py
Run all the tests from the root of the Pillow source distribution::
Or::
pytest -vx Tests
Or with coverage::
pytest -vx --cov PIL --cov-report term Tests
coverage html
open htmlcov/index.html
**If Pillow has been installed**
To run an individual test::
pytest -k Tests/test_image.py
pytest -k test_image.py
Run all the tests from the root of the Pillow source distribution::
pytest
Or with coverage::
pytest --cov PIL --cov-report term
coverage html
open htmlcov/index.html

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
import PIL
import PIL.Image
@ -24,7 +24,3 @@ class TestSanity(PillowTestCase):
PIL.Image.new("RGB", (100, 100))
PIL.Image.new("I", (100, 100))
PIL.Image.new("F", (100, 100))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import _binary
@ -22,7 +22,3 @@ class TestBinary(PillowTestCase):
self.assertEqual(_binary.o16be(65535), b'\xff\xff')
self.assertEqual(_binary.o32be(65535), b'\x00\x00\xff\xff')
if __name__ == '__main__':
unittest.main()

View File

@ -1,5 +1,5 @@
from __future__ import print_function
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
import os
@ -103,7 +103,3 @@ class TestBmpReference(PillowTestCase):
os.path.join(base, 'g', 'pal4rle.bmp'))
if f not in unsupported:
self.fail("Unsupported Image %s: %s" % (f, msg))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, ImageFilter
@ -215,7 +215,3 @@ class TestBoxBlur(PillowTestCase):
passes=3,
delta=1,
)
if __name__ == '__main__':
unittest.main()

View File

@ -519,7 +519,3 @@ class TestTransformColorLut3D(PillowTestCase):
self.assertEqual(lut.table[0:16], [
0.0, 0.0, 0.0, 0.5, 0.25, 0.0, 0.0, 0.5,
0.0, 0.0, 0.0, 0.5, 0.0, 0.16, 0.0, 0.5])
if __name__ == '__main__':
unittest.main()

View File

@ -179,7 +179,3 @@ class TestEnvVars(PillowTestCase):
self.assert_warning(
UserWarning, Image._apply_env_variables,
{'PILLOW_BLOCKS_MAX': 'wat'})
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -83,7 +83,3 @@ class TestDecompressionCrop(PillowTestCase):
for value in error_values:
with self.assertRaises(Image.DecompressionBombError):
im.crop(value)
if __name__ == '__main__':
unittest.main()

View File

@ -63,7 +63,3 @@ class TestFeatures(PillowTestCase):
module = "unsupported_module"
# Act / Assert
self.assertRaises(ValueError, features.check_module, module)
if __name__ == '__main__':
unittest.main()

View File

@ -1,6 +1,6 @@
from PIL import Image
from .helper import PillowTestCase, unittest
from .helper import PillowTestCase
class TestFileBlp(PillowTestCase):
@ -18,7 +18,3 @@ class TestFileBlp(PillowTestCase):
im = Image.open("Tests/images/blp/blp2_dxt1a.blp")
target = Image.open("Tests/images/blp/blp2_dxt1a.png")
self.assert_image_equal(im, target)
if __name__ == "__main__":
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, BmpImagePlugin
import io
@ -75,7 +75,3 @@ class TestFileBmp(PillowTestCase):
im = BmpImagePlugin.DibImageFile('Tests/images/clipboard.dib')
target = Image.open('Tests/images/clipboard_target.png')
self.assert_image_equal(im, target)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import BufrStubImagePlugin, Image
@ -40,7 +40,3 @@ class TestFileBufrStub(PillowTestCase):
# Act / Assert: stub cannot save without an implemented handler
self.assertRaises(IOError, im.save, tmpfile)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
from PIL import ContainerIO
@ -123,7 +123,3 @@ class TestFileContainer(PillowTestCase):
# Assert
self.assertEqual(data, expected)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, CurImagePlugin
@ -29,7 +29,3 @@ class TestFileCur(PillowTestCase):
cur.fp.close()
with open(no_cursors_file, "rb") as cur.fp:
self.assertRaises(TypeError, cur._open)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, DcxImagePlugin
@ -64,7 +64,3 @@ class TestFileDcx(PillowTestCase):
# Act / Assert
self.assertRaises(EOFError, im.seek, frame)
if __name__ == '__main__':
unittest.main()

View File

@ -1,6 +1,6 @@
from io import BytesIO
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, DdsImagePlugin
TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds"
@ -110,7 +110,3 @@ class TestFileDds(PillowTestCase):
im.load()
self.assertRaises(IOError, short_file)
if __name__ == '__main__':
unittest.main()

View File

@ -251,7 +251,3 @@ class TestFileEps(PillowTestCase):
self.assertEqual(image.mode, "RGB")
self.assertEqual(image.size, (460, 352))
self.assertEqual(image.format, "EPS")
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import FitsStubImagePlugin, Image
@ -44,7 +44,3 @@ class TestFileFitsStub(PillowTestCase):
self.assertRaises(
IOError,
FitsStubImagePlugin._save, im, dummy_fp, dummy_filename)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, FliImagePlugin
@ -97,7 +97,3 @@ class TestFileFli(PillowTestCase):
expected = Image.open("Tests/images/a_fli.png")
self.assert_image_equal(im, expected)
if __name__ == '__main__':
unittest.main()

View File

@ -21,7 +21,3 @@ class TestFileFpx(PillowTestCase):
ole_file = "Tests/images/test-ole-file.doc"
self.assertRaises(SyntaxError,
FpxImagePlugin.FpxImageFile, ole_file)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -14,7 +14,3 @@ class TestFileFtex(PillowTestCase):
im = Image.open('Tests/images/ftex_dxt1.ftc')
target = Image.open('Tests/images/ftex_dxt1.png')
self.assert_image_similar(im, target.convert('RGBA'), 15)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, GbrImagePlugin
@ -17,7 +17,3 @@ class TestFileGbr(PillowTestCase):
target = Image.open('Tests/images/gbr.png')
self.assert_image_equal(target, im)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import GdImageFile
@ -20,7 +20,3 @@ class TestFileGd(PillowTestCase):
invalid_file = "Tests/images/flower.jpg"
self.assertRaises(IOError, GdImageFile.open, invalid_file)
if __name__ == '__main__':
unittest.main()

View File

@ -654,7 +654,3 @@ class TestFileGif(PillowTestCase):
self.assertEqual(im.tile[0][3][0], 11) # LZW bits
# codec error prepatch
im.load()
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import GimpGradientFile
@ -119,7 +119,3 @@ class TestImage(PillowTestCase):
# load returns raw palette information
self.assertEqual(len(palette[0]), 1024)
self.assertEqual(palette[1], "RGBA")
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL.GimpPaletteFile import GimpPaletteFile
@ -28,7 +28,3 @@ class TestImage(PillowTestCase):
# Assert
self.assertEqual(mode, "RGB")
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import GribStubImagePlugin, Image
@ -40,7 +40,3 @@ class TestFileGribStub(PillowTestCase):
# Act / Assert: stub cannot save without an implemented handler
self.assertRaises(IOError, im.save, tmpfile)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Hdf5StubImagePlugin, Image
@ -44,7 +44,3 @@ class TestFileHdf5Stub(PillowTestCase):
self.assertRaises(
IOError,
Hdf5StubImagePlugin._save, im, dummy_fp, dummy_filename)
if __name__ == '__main__':
unittest.main()

View File

@ -121,7 +121,3 @@ class TestFileIcns(PillowTestCase):
with io.BytesIO(b'invalid\n') as fp:
self.assertRaises(SyntaxError,
IcnsImagePlugin.IcnsFile, fp)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
import io
from PIL import Image, IcoImagePlugin
@ -82,7 +82,3 @@ class TestFileIco(PillowTestCase):
self.assertEqual(
im_saved.info['sizes'],
{(16, 16), (24, 24), (32, 32), (48, 48)})
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, ImImagePlugin
@ -69,7 +69,3 @@ class TestFileIm(PillowTestCase):
def test_number(self):
self.assertEqual(1.2, ImImagePlugin.number("1.2"))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, IptcImagePlugin
@ -69,7 +69,3 @@ class TestFileIptc(PillowTestCase):
# Assert
self.assertEqual(mystdout.getvalue(), "61 62 63 \n")
if __name__ == '__main__':
unittest.main()

View File

@ -611,7 +611,3 @@ class TestFileCloseW32(PillowTestCase):
self.assertTrue(fp.closed)
# this should not fail, as load should have closed the file.
os.remove(tmpfile)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, Jpeg2KImagePlugin
from io import BytesIO
@ -210,7 +210,3 @@ class TestFileJpeg2k(PillowTestCase):
# Assert
self.assertEqual(p.image.size, (640, 480))
if __name__ == '__main__':
unittest.main()

View File

@ -1,5 +1,5 @@
from __future__ import print_function
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import features
from PIL._util import py3
@ -700,7 +700,3 @@ class TestFileLibTiff(LibTiffTestCase):
im = Image.open(infile)
self.assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)
if __name__ == '__main__':
unittest.main()

View File

@ -1,5 +1,3 @@
from .helper import unittest
from PIL import Image
from .test_file_libtiff import LibTiffTestCase
@ -46,7 +44,3 @@ class TestFileLibTiffSmall(LibTiffTestCase):
self.assertEqual(im.size, (128, 128))
self._assert_noerr(im)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, McIdasImagePlugin
@ -28,7 +28,3 @@ class TestFileMcIdas(PillowTestCase):
self.assertEqual(im.size, (1800, 400))
im2 = Image.open(saved_file)
self.assert_image_equal(im, im2)
if __name__ == '__main__':
unittest.main()

View File

@ -64,7 +64,3 @@ class TestFileMic(PillowTestCase):
ole_file = "Tests/images/test-ole-file.doc"
self.assertRaises(SyntaxError,
MicImagePlugin.MicImageFile, ole_file)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from io import BytesIO
from PIL import Image
@ -150,7 +150,3 @@ class TestFileMpo(PillowTestCase):
self.assertEqual(im.tell(), 1)
jpg1 = self.frame_roundtrip(im)
self.assert_image_similar(im, jpg1, 30)
if __name__ == '__main__':
unittest.main()

View File

@ -78,7 +78,3 @@ class TestFileMsp(PillowTestCase):
# Act/Assert
self.assertRaises(IOError, im.save, filename)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper, imagemagick_available
from .helper import PillowTestCase, hopper, imagemagick_available
import os.path
@ -52,7 +52,3 @@ class TestFilePalm(PillowTestCase):
# Act / Assert
self.assertRaises(IOError, self.helper_save_as_palm, mode)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -16,7 +16,3 @@ class TestFilePcd(PillowTestCase):
# target = hopper().resize((768,512))
# self.assert_image_similar(im, target, 10)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, ImageFile, PcxImagePlugin
@ -128,7 +128,3 @@ class TestFilePcx(PillowTestCase):
for x in range(5):
px[x, 3] = 0
self._test_buffer_overflow(im)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, PdfParser
import io
import os
@ -266,7 +266,3 @@ class TestFilePdf(PillowTestCase):
f = io.BytesIO(f.getvalue())
im.save(f, format="PDF", append=True)
self.assertGreater(len(f.getvalue()), initial_size)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import hopper, unittest, PillowTestCase
from .helper import hopper, PillowTestCase
from PIL import Image, PixarImagePlugin
@ -24,7 +24,3 @@ class TestFilePixar(PillowTestCase):
self.assertRaises(
SyntaxError,
PixarImagePlugin.PixarImageFile, invalid_file)
if __name__ == '__main__':
unittest.main()

View File

@ -626,7 +626,3 @@ class TestTruncatedPngPLeaks(PillowLeakTestCase):
self._test_leak(core)
finally:
ImageFile.LOAD_TRUNCATED_IMAGES = False
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -49,7 +49,3 @@ class TestFilePpm(PillowTestCase):
with self.assertRaises(IOError):
Image.open('Tests/images/negative_size.ppm')
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import hopper, unittest, PillowTestCase
from .helper import hopper, PillowTestCase
from PIL import Image, PsdImagePlugin
@ -76,7 +76,3 @@ class TestImagePsd(PillowTestCase):
im = Image.open("Tests/images/hopper_merged.psd")
self.assertNotIn("icc_profile", im.info)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, SgiImagePlugin
@ -89,7 +89,3 @@ class TestFileSgi(PillowTestCase):
out = self.tempfile('temp.sgi')
self.assertRaises(ValueError, im.save, out, format='sgi')
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
from PIL import ImageSequence
@ -119,7 +119,3 @@ class TestImageSpider(PillowTestCase):
for i, frame in enumerate(ImageSequence.Iterator(im)):
if i > 1:
self.fail("Non-stack DOS file test failed")
if __name__ == '__main__':
unittest.main()

View File

@ -45,7 +45,3 @@ class TestFileSun(PillowTestCase):
# im.save(target_file)
with Image.open(target_path) as target:
self.assert_image_equal(im, target)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, TarIO
@ -34,7 +34,3 @@ class TestFileTar(PillowTestCase):
def test_contextmanager(self):
with TarIO.TarIO(TEST_TAR_FILE, 'hopper.jpg'):
pass
if __name__ == '__main__':
unittest.main()

View File

@ -2,7 +2,7 @@ import os
from glob import glob
from itertools import product
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -201,7 +201,3 @@ class TestFileTga(PillowTestCase):
test_im.getchannel("A").getcolors()[0][0], num_transparent)
self.assert_image_equal(im, test_im)
if __name__ == '__main__':
unittest.main()

View File

@ -565,7 +565,3 @@ class TestFileTiffW32(PillowTestCase):
# this should not fail, as load should have closed the file pointer,
# and close should have closed the mmap
os.remove(tmpfile)
if __name__ == '__main__':
unittest.main()

View File

@ -1,7 +1,7 @@
import io
import struct
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, TiffImagePlugin, TiffTags
from PIL.TiffImagePlugin import _limit_rational, IFDRational
@ -247,7 +247,3 @@ class TestFileTiffMetadata(PillowTestCase):
# Should not raise ValueError.
self.assert_warning(UserWarning, lambda: ifd[277])
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import WalImageFile
@ -17,7 +17,3 @@ class TestFileWal(PillowTestCase):
self.assertEqual(im.format_description, "Quake2 Texture")
self.assertEqual(im.mode, "P")
self.assertEqual(im.size, (128, 128))
if __name__ == '__main__':
unittest.main()

View File

@ -172,7 +172,3 @@ class TestFileWebp(PillowTestCase):
difference = sum([abs(original_value[i] - reread_value[i])
for i in range(0, 3)])
self.assertLess(difference, 5)
if __name__ == '__main__':
unittest.main()

View File

@ -115,7 +115,3 @@ class TestFileWebpAlpha(PillowTestCase):
target = Image.open(file_path).convert("RGBA")
self.assert_image_similar(image, target, 25.0)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -151,7 +151,3 @@ class TestFileWebpAnimation(PillowTestCase):
self.assertEqual(im.info["duration"], dur)
self.assertEqual(im.info["timestamp"], ts)
ts -= dur
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -36,7 +36,3 @@ class TestFileWebpLossless(PillowTestCase):
image.getdata()
self.assert_image_equal(image, hopper(self.rgb_mode))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -133,7 +133,3 @@ class TestFileWebpMetadata(PillowTestCase):
self.assertEqual(iccp_data, image.info.get('icc_profile', None))
self.assertEqual(exif_data, image.info.get('exif', None))
self.assertEqual(xmp_data, image.info.get('xmp', None))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
from PIL import WmfImagePlugin
@ -51,7 +51,3 @@ class TestFileWmf(PillowTestCase):
for ext in [".wmf", ".emf"]:
tmpfile = self.tempfile("temp"+ext)
self.assertRaises(IOError, im.save, tmpfile)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -60,7 +60,3 @@ class TestFileXbm(PillowTestCase):
# Assert
self.assertEqual(im.mode, '1')
self.assertEqual(im.size, (128, 128))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, XpmImagePlugin
@ -33,7 +33,3 @@ class TestFileXpm(PillowTestCase):
# Assert
self.assertEqual(len(data), 16384)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import hopper, unittest, PillowTestCase
from .helper import hopper, PillowTestCase
from PIL import Image, XVThumbImagePlugin
@ -34,7 +34,3 @@ class TestFileXVThumb(PillowTestCase):
# Act / Assert
self.assertRaises(SyntaxError,
XVThumbImagePlugin.XVThumbImageFile, invalid_file)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import FontFile, BdfFontFile
@ -18,7 +18,3 @@ class TestFontBdf(PillowTestCase):
def test_invalid_file(self):
with open("Tests/images/flower.jpg", "rb") as fp:
self.assertRaises(SyntaxError, BdfFontFile.BdfFontFile, fp)
if __name__ == '__main__':
unittest.main()

View File

@ -31,7 +31,3 @@ class TestDefaultFontLeak(TestTTypeFontLeak):
def test_leak(self):
default_font = ImageFont.load_default()
self._test_font(default_font)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image, FontFile, PcfFontFile
from PIL import ImageFont, ImageDraw
@ -79,7 +79,3 @@ class TestFontPcf(PillowTestCase):
# accept bytes instances in Py3.
if py3:
self._test_high_characters(message.encode('latin1'))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
from PIL._util import py3
@ -129,7 +129,3 @@ class TestFormatHSV(PillowTestCase):
self.assert_image_similar(converted.getchannel(2),
comparable.getchannel(2),
3, "B conversion is wrong")
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -40,7 +40,3 @@ class TestFormatLab(PillowTestCase):
k = i.getpixel((0, 0))
self.assertEqual(k, (128, 228, 128))
if __name__ == '__main__':
unittest.main()

View File

@ -560,7 +560,3 @@ class TestRegistry(PillowTestCase):
'DoesNotExist',
('args',),
extra=('extra',))
if __name__ == '__main__':
unittest.main()

View File

@ -366,7 +366,3 @@ int main(int argc, char* argv[])
process = subprocess.Popen(['embed_pil.exe'], env=env)
process.communicate()
self.assertEqual(process.returncode, 0)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -55,7 +55,3 @@ class TestImageArray(PillowTestCase):
self.assertEqual(test("RGB"), ("RGB", (128, 100), True))
self.assertEqual(test("RGBA"), ("RGBA", (128, 100), True))
self.assertEqual(test("RGBX"), ("RGBA", (128, 100), True))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -230,7 +230,3 @@ class TestImageConvert(PillowTestCase):
# Assert
# No change
self.assert_image_equal(converted_im, im)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -40,7 +40,3 @@ class TestImageCopy(PillowTestCase):
out = im.copy()
self.assertEqual(out.mode, im.mode)
self.assertEqual(out.size, im.size)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -102,7 +102,3 @@ class TestImageCrop(PillowTestCase):
cropped = im.crop((10, 10, 20, 20))
self.assertEqual(cropped.size, (10, 10))
self.assertEqual(cropped.getdata()[2], (0, 0, 0))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, fromstring, tostring
from .helper import PillowTestCase, fromstring, tostring
from PIL import Image
@ -69,7 +69,3 @@ class TestImageDraft(PillowTestCase):
im = self.draft_roundtrip('L', (128, 128), None, (64, 64))
im.draft(None, (64, 64))
im.load()
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image, ImageFilter
@ -136,7 +136,3 @@ class TestImageFilter(PillowTestCase):
Image.merge(mode, source[:len(mode)]).filter(kernel),
Image.merge(mode, reference[:len(mode)]),
)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -13,7 +13,3 @@ class TestImageFromBytes(PillowTestCase):
def test_not_implemented(self):
self.assertRaises(NotImplementedError, Image.fromstring)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from .test_imageqt import PillowQtTestCase
from PIL import ImageQt, Image
@ -42,7 +42,3 @@ class TestFromQImage(PillowQtTestCase, PillowTestCase):
def test_sanity_p(self):
for im in self.files_to_test:
self.roundtrip(im.convert('P'))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -18,7 +18,3 @@ class TestImageGetBands(PillowTestCase):
Image.new("CMYK", (1, 1)).getbands(), ("C", "M", "Y", "K"))
self.assertEqual(
Image.new("YCbCr", (1, 1)).getbands(), ("Y", "Cb", "Cr"))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -37,7 +37,3 @@ class TestImageGetBbox(PillowTestCase):
im.paste(255, (-10, -10, 110, 110))
self.assertEqual(im.getbbox(), (0, 0, 100, 100))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImageGetColors(PillowTestCase):
@ -65,7 +65,3 @@ class TestImageGetColors(PillowTestCase):
A = im.getcolors(maxcolors=16)
A.sort()
self.assertEqual(A, expected)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImageGetData(PillowTestCase):
@ -27,7 +27,3 @@ class TestImageGetData(PillowTestCase):
self.assertEqual(getdata("RGBA"), ((11, 13, 52, 255), 960, 960))
self.assertEqual(getdata("CMYK"), ((244, 242, 203, 0), 960, 960))
self.assertEqual(getdata("YCbCr"), ((16, 147, 123), 960, 960))
if __name__ == '__main__':
unittest.main()

View File

@ -1,5 +1,5 @@
from PIL import Image
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImageGetExtrema(PillowTestCase):
@ -27,7 +27,3 @@ class TestImageGetExtrema(PillowTestCase):
self.assertEqual(im.mode, 'I;16')
extrema = im.getextrema()
self.assertEqual(extrema, (106, 285))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL._util import py3
@ -12,7 +12,3 @@ class TestImageGetIm(PillowTestCase):
self.assertIn("PyCapsule", type_repr)
self.assertIsInstance(im.im.id, int)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImageGetPalette(PillowTestCase):
@ -18,7 +18,3 @@ class TestImageGetPalette(PillowTestCase):
self.assertIsNone(palette("RGBA"))
self.assertIsNone(palette("CMYK"))
self.assertIsNone(palette("YCbCr"))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -30,7 +30,3 @@ class TestImageGetProjection(PillowTestCase):
im.paste(255, (2, 4, 8, 6))
self.assertEqual(im.getprojection()[0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0])
self.assertEqual(im.getprojection()[1], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0])
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImageHistogram(PillowTestCase):
@ -18,7 +18,3 @@ class TestImageHistogram(PillowTestCase):
self.assertEqual(histogram("RGBA"), (1024, 0, 16384))
self.assertEqual(histogram("CMYK"), (1024, 0, 16384))
self.assertEqual(histogram("YCbCr"), (768, 0, 1908))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -28,7 +28,3 @@ class TestImageLoad(PillowTestCase):
os.fstat(fn)
self.assertRaises(OSError, os.fstat, fn)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -51,7 +51,3 @@ class TestImageMode(PillowTestCase):
check("RGBX", "RGB", "L", 4, ("R", "G", "B", "X"))
check("CMYK", "RGB", "L", 4, ("C", "M", "Y", "K"))
check("YCbCr", "RGB", "L", 3, ("Y", "Cb", "Cr"))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, cached_property
from .helper import PillowTestCase, cached_property
from PIL import Image
@ -250,7 +250,3 @@ class TestImagingPaste(PillowTestCase):
im.copy().paste(im2)
im.copy().paste(im2, (0, 0))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
class TestImagePoint(PillowTestCase):
@ -38,7 +38,3 @@ class TestImagePoint(PillowTestCase):
def test_f_mode(self):
im = hopper('F')
self.assertRaises(ValueError, im.point, None)
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase
from .helper import PillowTestCase
from PIL import Image
@ -44,7 +44,3 @@ class TestImagePutAlpha(PillowTestCase):
self.assertFalse(im.readonly)
self.assertEqual(im.mode, 'RGBA')
self.assertEqual(im.getpixel((0, 0)), (1, 2, 3, 4))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from array import array
import sys
@ -83,7 +83,3 @@ class TestImagePutData(PillowTestCase):
im.putdata(arr)
self.assertEqual(len(im.getdata()), len(arr))
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import ImagePalette
@ -28,7 +28,3 @@ class TestImagePutPalette(PillowTestCase):
im.putpalette(ImagePalette.random())
im.putpalette(ImagePalette.sepia())
im.putpalette(ImagePalette.wedge())
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -46,7 +46,3 @@ class TestImageQuantize(PillowTestCase):
converted = image.quantize()
self.assert_image(converted, 'P', converted.size)
self.assert_image_similar(converted.convert('RGB'), image, 1)
if __name__ == '__main__':
unittest.main()

View File

@ -544,7 +544,3 @@ class CoreResampleBoxTest(PillowTestCase):
except AssertionError:
print('>>>', size, box, flt)
raise
if __name__ == '__main__':
unittest.main()

View File

@ -3,7 +3,7 @@ Tests for resize functionality.
"""
from itertools import permutations
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -115,7 +115,3 @@ class TestImageResize(PillowTestCase):
# Test unknown resampling filter
im = hopper()
self.assertRaises(ValueError, im.resize, (10, 10), "unknown")
if __name__ == '__main__':
unittest.main()

View File

@ -1,4 +1,4 @@
from .helper import unittest, PillowTestCase, hopper
from .helper import PillowTestCase, hopper
from PIL import Image
@ -123,7 +123,3 @@ class TestImageRotate(PillowTestCase):
im = im.rotate(45, expand=1, fillcolor=(255, 0, 0, 255))
corner = im.getpixel((0, 0))
self.assertEqual(corner, (255, 0, 0, 255))
if __name__ == '__main__':
unittest.main()

Some files were not shown because too many files have changed in this diff Show More