Skip to content

Commit

Permalink
Improve pytest configuration to allow specific tests as CLI args
Browse files Browse the repository at this point in the history
The previous test configuration made it difficult to run a single test
with the pytest CLI. There were two major issues:

- The Tests directory was not a package. It now includes a __init__.py
  file and imports from other tests modules are done with relative
  imports.

- setup.cfg always specified the Tests directory. So even if a specific
  test were specified as a CLI arg, this configuration would also always
  include all tests. This configuration has been removed to allow
  specifying a single test on the command line.

Contributors can now run specific tests with a single command such as:

  $ tox -e py37 -- Tests/test_file_pdf.py::TestFilePdf.test_rgb

This makes it easy and faster to iterate on a single test failure and is
very familiar to those that have previously used tox and pytest.

When running tox or pytest with no arguments, they still discover and
runs all tests in the Tests directory.
  • Loading branch information
jdufresne committed Jan 13, 2019
1 parent b62ff51 commit 7da17ad
Show file tree
Hide file tree
Showing 161 changed files with 167 additions and 170 deletions.
Empty file added Tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion Tests/bench_cffi_access.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

# Not running this test by default. No DOS against Travis CI.

Expand Down
2 changes: 1 addition & 1 deletion Tests/bench_get.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import helper
from . import helper
import timeit

import sys
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_fli_overflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image

TEST_FILE = "Tests/images/fli_overflow.fli"
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_imaging_leaks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

from __future__ import division
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
import sys
from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/check_j2k_leaks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
import sys
from PIL import Image
from io import BytesIO
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_j2k_overflow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PIL import Image
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase


class TestJ2kEncodeOverflow(PillowTestCase):
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_jpeg_leaks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper
from io import BytesIO
import sys

Expand Down
2 changes: 1 addition & 1 deletion Tests/check_large_memory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

# This test is not run automatically.
#
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_large_memory_numpy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

# This test is not run automatically.
#
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_libtiff_segfault.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image

TEST_FILE = "Tests/images/libtiff_segfault.tif"
Expand Down
2 changes: 1 addition & 1 deletion Tests/check_png_dos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image, PngImagePlugin, ImageFile
from io import BytesIO
import zlib
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_000_sanity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

import PIL
import PIL.Image
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_binary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import _binary

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_bmp_reference.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import print_function
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image
import os
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_box_blur.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, ImageFilter

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_color_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from array import array

from PIL import Image, ImageFilter
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

try:
import numpy
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_core_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image


Expand Down
2 changes: 1 addition & 1 deletion Tests/test_decompression_bomb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_features.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import features

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_blp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PIL import Image

from helper import PillowTestCase, unittest
from .helper import PillowTestCase, unittest


class TestFileBlp(PillowTestCase):
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_bmp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, BmpImagePlugin
import io
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_bufrstub.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import BufrStubImagePlugin, Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_container.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image
from PIL import ContainerIO
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_cur.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, CurImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_dcx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, DcxImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_dds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from io import BytesIO

from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image, DdsImagePlugin

TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds"
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_eps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, EpsImagePlugin
import io
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_fitsstub.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import FitsStubImagePlugin, Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_fli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, FliImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_fpx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

try:
from PIL import FpxImagePlugin
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_ftex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image


Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gbr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, GbrImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import GdImageFile

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gif.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper, netpbm_available
from .helper import unittest, PillowTestCase, hopper, netpbm_available

from PIL import Image, ImagePalette, GifImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gimpgradient.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import GimpGradientFile

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gimppalette.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL.GimpPaletteFile import GimpPaletteFile

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_gribstub.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import GribStubImagePlugin, Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Hdf5StubImagePlugin, Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_icns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, IcnsImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_ico.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

import io
from PIL import Image, IcoImagePlugin
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_im.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, ImImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_iptc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, IptcImagePlugin

Expand Down
4 changes: 2 additions & 2 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from helper import unittest, PillowTestCase, hopper
from helper import djpeg_available, cjpeg_available
from .helper import unittest, PillowTestCase, hopper
from .helper import djpeg_available, cjpeg_available

from io import BytesIO
import os
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_jpeg2k.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, Jpeg2KImagePlugin
from io import BytesIO
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import print_function
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper
from PIL import features
from PIL._util import py3

Expand Down
4 changes: 2 additions & 2 deletions Tests/test_file_libtiff_small.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from helper import unittest
from .helper import unittest

from PIL import Image

from test_file_libtiff import LibTiffTestCase
from .test_file_libtiff import LibTiffTestCase


class TestFileLibTiffSmall(LibTiffTestCase):
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_mcidas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, McIdasImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_mic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, ImagePalette, features

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_mpo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from io import BytesIO
from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_msp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, MspImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_palm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper, imagemagick_available
from .helper import unittest, PillowTestCase, hopper, imagemagick_available

import os.path

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_pcd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase
from PIL import Image


Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_pcx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, ImageFile, PcxImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_pdf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper
from PIL import Image, PdfParser
import io
import os
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_pixar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import hopper, unittest, PillowTestCase
from .helper import hopper, unittest, PillowTestCase

from PIL import Image, PixarImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_png.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, PillowLeakTestCase, hopper
from .helper import unittest, PillowTestCase, PillowLeakTestCase, hopper
from PIL import Image, ImageFile, PngImagePlugin
from PIL._util import py3

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_ppm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_psd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import hopper, unittest, PillowTestCase
from .helper import hopper, unittest, PillowTestCase

from PIL import Image, PsdImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_sgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, SgiImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_spider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image
from PIL import ImageSequence
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_sun.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase, hopper
from .helper import unittest, PillowTestCase, hopper

from PIL import Image, SunImagePlugin

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_tar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from .helper import unittest, PillowTestCase

from PIL import Image, TarIO

Expand Down
Loading

0 comments on commit 7da17ad

Please sign in to comment.