Import unittest from stdlib rather than helper.py

The unittest in helper.py has not offered an interesting abstraction
since dbe9f85c7d so import from the more
typical stdlib location.
This commit is contained in:
Jon Dufresne 2019-11-20 18:42:52 -08:00
parent f90a21965a
commit 33dabf986f
45 changed files with 108 additions and 45 deletions

View File

@ -1,8 +1,9 @@
import time import time
import unittest
from PIL import PyAccess from PIL import PyAccess
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
# Not running this test by default. No DOS against Travis CI. # Not running this test by default. No DOS against Travis CI.

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
TEST_FILE = "Tests/images/fli_overflow.fli" TEST_FILE = "Tests/images/fli_overflow.fli"

View File

@ -1,7 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, is_win32, unittest from .helper import PillowTestCase, is_win32
min_iterations = 100 min_iterations = 100
max_iterations = 10000 max_iterations = 10000

View File

@ -1,8 +1,9 @@
import unittest
from io import BytesIO from io import BytesIO
from PIL import Image from PIL import Image
from .helper import PillowTestCase, is_win32, unittest from .helper import PillowTestCase, is_win32
# Limits for testing the leak # Limits for testing the leak
mem_limit = 1024 * 1048576 mem_limit = 1024 * 1048576

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
class TestJ2kEncodeOverflow(PillowTestCase): class TestJ2kEncodeOverflow(PillowTestCase):

View File

@ -1,6 +1,7 @@
import unittest
from io import BytesIO from io import BytesIO
from .helper import PillowTestCase, hopper, is_win32, unittest from .helper import PillowTestCase, hopper, is_win32
iterations = 5000 iterations = 5000

View File

@ -1,8 +1,9 @@
import sys import sys
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
# This test is not run automatically. # This test is not run automatically.
# #

View File

@ -1,8 +1,9 @@
import sys import sys
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
# This test is not run automatically. # This test is not run automatically.
# #

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
TEST_FILE = "Tests/images/libtiff_segfault.tif" TEST_FILE = "Tests/images/libtiff_segfault.tif"

View File

@ -1,9 +1,10 @@
import unittest
import zlib import zlib
from io import BytesIO from io import BytesIO
from PIL import Image, ImageFile, PngImagePlugin from PIL import Image, ImageFile, PngImagePlugin
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
TEST_FILE = "Tests/images/png_decompression_dos.png" TEST_FILE = "Tests/images/png_decompression_dos.png"

View File

@ -1,8 +1,9 @@
import unittest
from array import array from array import array
from PIL import Image, ImageFilter from PIL import Image, ImageFilter
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
try: try:
import numpy import numpy

View File

@ -1,8 +1,9 @@
import sys import sys
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, is_pypy, unittest from .helper import PillowTestCase, is_pypy
class TestCoreStats(PillowTestCase): class TestCoreStats(PillowTestCase):

View File

@ -1,8 +1,9 @@
import io import io
import unittest
from PIL import features from PIL import features
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
try: try:
from PIL import _webp from PIL import _webp

View File

@ -1,8 +1,9 @@
import io import io
import unittest
from PIL import EpsImagePlugin, Image from PIL import EpsImagePlugin, Image
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript() HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()

View File

@ -1,4 +1,6 @@
from .helper import PillowTestCase, unittest import unittest
from .helper import PillowTestCase
try: try:
from PIL import FpxImagePlugin from PIL import FpxImagePlugin

View File

@ -1,8 +1,9 @@
import unittest
from io import BytesIO from io import BytesIO
from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette
from .helper import PillowTestCase, hopper, is_pypy, netpbm_available, unittest from .helper import PillowTestCase, hopper, is_pypy, netpbm_available
try: try:
from PIL import _webp from PIL import _webp

View File

@ -1,9 +1,10 @@
import io import io
import sys import sys
import unittest
from PIL import IcnsImagePlugin, Image from PIL import IcnsImagePlugin, Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
# sample icon file # sample icon file
TEST_FILE = "Tests/images/pillow.icns" TEST_FILE = "Tests/images/pillow.icns"

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, ImagePalette, features from PIL import Image, ImagePalette, features
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
try: try:
from PIL import MicImagePlugin from PIL import MicImagePlugin

View File

@ -1,8 +1,9 @@
import os import os
import unittest
from PIL import Image, MspImagePlugin from PIL import Image, MspImagePlugin
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
TEST_FILE = "Tests/images/hopper.msp" TEST_FILE = "Tests/images/hopper.msp"
EXTRA_DIR = "Tests/images/picins" EXTRA_DIR = "Tests/images/picins"

View File

@ -1,9 +1,10 @@
import unittest
import zlib import zlib
from io import BytesIO from io import BytesIO
from PIL import Image, ImageFile, PngImagePlugin from PIL import Image, ImageFile, PngImagePlugin
from .helper import PillowLeakTestCase, PillowTestCase, hopper, is_win32, unittest from .helper import PillowLeakTestCase, PillowTestCase, hopper, is_win32
try: try:
from PIL import _webp from PIL import _webp

View File

@ -1,8 +1,9 @@
import os import os
import unittest
from PIL import Image, SunImagePlugin from PIL import Image, SunImagePlugin
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
EXTRA_DIR = "Tests/images/sunraster" EXTRA_DIR = "Tests/images/sunraster"

View File

@ -1,12 +1,13 @@
import logging import logging
import os import os
import unittest
from io import BytesIO from io import BytesIO
import pytest import pytest
from PIL import Image, TiffImagePlugin from PIL import Image, TiffImagePlugin
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
from .helper import PillowTestCase, hopper, is_pypy, is_win32, unittest from .helper import PillowTestCase, hopper, is_pypy, is_win32
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, WebPImagePlugin from PIL import Image, WebPImagePlugin
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
try: try:
from PIL import _webp from PIL import _webp

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
try: try:
from PIL import _webp from PIL import _webp

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, ImageDraw, ImageFont, features from PIL import Image, ImageDraw, ImageFont, features
from .helper import PillowLeakTestCase, is_win32, unittest from .helper import PillowLeakTestCase, is_win32
@unittest.skipIf(is_win32(), "requires Unix or macOS") @unittest.skipIf(is_win32(), "requires Unix or macOS")

View File

@ -1,10 +1,11 @@
import os import os
import shutil import shutil
import tempfile import tempfile
import unittest
from PIL import Image, UnidentifiedImageError from PIL import Image, UnidentifiedImageError
from .helper import PillowTestCase, hopper, is_win32, unittest from .helper import PillowTestCase, hopper, is_win32
class TestImage(PillowTestCase): class TestImage(PillowTestCase):

View File

@ -2,11 +2,12 @@ import ctypes
import os import os
import subprocess import subprocess
import sys import sys
import unittest
from distutils import ccompiler, sysconfig from distutils import ccompiler, sysconfig
from PIL import Image from PIL import Image
from .helper import PillowTestCase, hopper, is_win32, on_ci, unittest from .helper import PillowTestCase, hopper, is_win32, on_ci
# CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2 # CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2
# https://github.com/eliben/pycparser/pull/198#issuecomment-317001670 # https://github.com/eliben/pycparser/pull/198#issuecomment-317001670

View File

@ -1,8 +1,9 @@
import unittest
from contextlib import contextmanager from contextlib import contextmanager
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
class TestImagingResampleVulnerability(PillowTestCase): class TestImagingResampleVulnerability(PillowTestCase):

View File

@ -1,8 +1,9 @@
import os.path import os.path
import unittest
from PIL import Image, ImageColor, ImageDraw, ImageFont, features from PIL import Image, ImageColor, ImageDraw, ImageFont, features
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)

View File

@ -1,8 +1,9 @@
import os.path import os.path
import unittest
from PIL import Image, ImageDraw2, features from PIL import Image, ImageDraw2, features
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)

View File

@ -1,8 +1,9 @@
import unittest
from io import BytesIO from io import BytesIO
from PIL import EpsImagePlugin, Image, ImageFile from PIL import EpsImagePlugin, Image, ImageFile
from .helper import PillowTestCase, fromstring, hopper, tostring, unittest from .helper import PillowTestCase, fromstring, hopper, tostring
try: try:
from PIL import _webp from PIL import _webp

View File

@ -4,11 +4,12 @@ import os
import re import re
import shutil import shutil
import sys import sys
import unittest
from io import BytesIO from io import BytesIO
from PIL import Image, ImageDraw, ImageFont, features from PIL import Image, ImageDraw, ImageFont, features
from .helper import PillowTestCase, is_pypy, is_win32, unittest from .helper import PillowTestCase, is_pypy, is_win32
FONT_PATH = "Tests/fonts/FreeMono.ttf" FONT_PATH = "Tests/fonts/FreeMono.ttf"
FONT_SIZE = 20 FONT_SIZE = 20

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
image_font_installed = True image_font_installed = True
try: try:

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, ImageDraw, ImageFont, features from PIL import Image, ImageDraw, ImageFont, features
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
FONT_SIZE = 20 FONT_SIZE = 20
FONT_PATH = "Tests/fonts/DejaVuSans.ttf" FONT_PATH = "Tests/fonts/DejaVuSans.ttf"

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image, ImageShow from PIL import Image, ImageShow
from .helper import PillowTestCase, hopper, is_win32, on_ci, on_github_actions, unittest from .helper import PillowTestCase, hopper, is_win32, on_ci, on_github_actions
class TestImageShow(PillowTestCase): class TestImageShow(PillowTestCase):

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
try: try:
from PIL import ImageTk from PIL import ImageTk

View File

@ -1,6 +1,8 @@
import unittest
from PIL import ImageWin from PIL import ImageWin
from .helper import PillowTestCase, hopper, is_win32, unittest from .helper import PillowTestCase, hopper, is_win32
class TestImageWin(PillowTestCase): class TestImageWin(PillowTestCase):

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
class TestLibImage(PillowTestCase): class TestLibImage(PillowTestCase):

View File

@ -1,8 +1,9 @@
import locale import locale
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
# ref https://github.com/python-pillow/Pillow/issues/272 # ref https://github.com/python-pillow/Pillow/issues/272
# on windows, in polish locale: # on windows, in polish locale:

View File

@ -1,9 +1,10 @@
import os import os
import subprocess import subprocess
import sys import sys
import unittest
from unittest import TestCase from unittest import TestCase
from .helper import is_pypy, is_win32, on_github_actions, unittest from .helper import is_pypy, is_win32, on_github_actions
class TestMain(TestCase): class TestMain(TestCase):

View File

@ -1,8 +1,9 @@
import sys import sys
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, is_win32, unittest from .helper import PillowTestCase, is_win32
try: try:
import numpy import numpy

View File

@ -1,6 +1,8 @@
import unittest
from PIL import Image from PIL import Image
from .helper import PillowTestCase, hopper, unittest from .helper import PillowTestCase, hopper
try: try:
import numpy import numpy

View File

@ -1,6 +1,8 @@
import unittest
from PIL import __version__ from PIL import __version__
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
try: try:
import pyroma import pyroma

View File

@ -1,6 +1,8 @@
import unittest
from PIL import _util from PIL import _util
from .helper import PillowTestCase, unittest from .helper import PillowTestCase
class TestUtil(PillowTestCase): class TestUtil(PillowTestCase):

View File

@ -1,8 +1,9 @@
import unittest
from io import BytesIO from io import BytesIO
from PIL import Image, features from PIL import Image, features
from .helper import PillowLeakTestCase, unittest from .helper import PillowLeakTestCase
test_file = "Tests/images/hopper.webp" test_file = "Tests/images/hopper.webp"