mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 19:45:56 +03:00
Fix tox test running: port selftest.py to Python 3; make it clear Python 2.5 is no longer supported (its support is broken in many ways in this branch); remove bundled doctest.py module (it is in stdlib since forever); remove extra stuff from tox.ini
This commit is contained in:
parent
c952134e00
commit
decabcf96a
48
selftest.py
48
selftest.py
|
@ -1,5 +1,5 @@
|
|||
# minimal sanity check
|
||||
|
||||
from __future__ import print_function
|
||||
ROOT = "."
|
||||
|
||||
import os, sys
|
||||
|
@ -13,7 +13,7 @@ from PIL import ImageMath
|
|||
try:
|
||||
Image.core.ping
|
||||
except ImportError as v:
|
||||
print "***", v
|
||||
print("***", v)
|
||||
sys.exit()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
@ -49,19 +49,19 @@ def testimage():
|
|||
('PPM', 'RGB', (128, 128))
|
||||
>>> try:
|
||||
... _info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
|
||||
... except IOError, v:
|
||||
... print v
|
||||
... except IOError as v:
|
||||
... print(v)
|
||||
('JPEG', 'RGB', (128, 128))
|
||||
|
||||
PIL doesn't actually load the image data until it's needed,
|
||||
or you call the "load" method:
|
||||
|
||||
>>> im = Image.open(os.path.join(ROOT, "Images/lena.ppm"))
|
||||
>>> print im.im # internal image attribute
|
||||
>>> print(im.im) # internal image attribute
|
||||
None
|
||||
>>> a = im.load()
|
||||
>>> type(im.im)
|
||||
<type 'ImagingCore'>
|
||||
>>> type(im.im) # doctest: +ELLIPSIS
|
||||
<... '...ImagingCore'>
|
||||
|
||||
You can apply many different operations on images. Most
|
||||
operations return a new image:
|
||||
|
@ -89,17 +89,17 @@ def testimage():
|
|||
2
|
||||
>>> len(im.histogram())
|
||||
768
|
||||
>>> _info(im.point(range(256)*3))
|
||||
>>> _info(im.point(list(range(256))*3))
|
||||
(None, 'RGB', (128, 128))
|
||||
>>> _info(im.resize((64, 64)))
|
||||
(None, 'RGB', (64, 64))
|
||||
>>> _info(im.rotate(45))
|
||||
(None, 'RGB', (128, 128))
|
||||
>>> map(_info, im.split())
|
||||
>>> [_info(ch) for ch in im.split()]
|
||||
[(None, 'L', (128, 128)), (None, 'L', (128, 128)), (None, 'L', (128, 128))]
|
||||
>>> len(im.convert("1").tobitmap())
|
||||
10456
|
||||
>>> len(im.tostring())
|
||||
>>> len(im.tobytes())
|
||||
49152
|
||||
>>> _info(im.transform((512, 512), Image.AFFINE, (1,0,0,0,1,0)))
|
||||
(None, 'RGB', (512, 512))
|
||||
|
@ -159,15 +159,15 @@ def check_module(feature, module):
|
|||
try:
|
||||
__import__("PIL." + module)
|
||||
except ImportError:
|
||||
print "***", feature, "support not installed"
|
||||
print("***", feature, "support not installed")
|
||||
else:
|
||||
print "---", feature, "support ok"
|
||||
print("---", feature, "support ok")
|
||||
|
||||
def check_codec(feature, codec):
|
||||
if codec + "_encoder" not in dir(Image.core):
|
||||
print "***", feature, "support not installed"
|
||||
print("***", feature, "support not installed")
|
||||
else:
|
||||
print "---", feature, "support ok"
|
||||
print("---", feature, "support ok")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -175,28 +175,28 @@ if __name__ == "__main__":
|
|||
|
||||
exit_status = 0
|
||||
|
||||
print "-"*68
|
||||
print "PIL", Image.VERSION, "TEST SUMMARY "
|
||||
print "-"*68
|
||||
print "Python modules loaded from", os.path.dirname(Image.__file__)
|
||||
print "Binary modules loaded from", os.path.dirname(Image.core.__file__)
|
||||
print "-"*68
|
||||
print("-"*68)
|
||||
print("PIL", Image.VERSION, "TEST SUMMARY ")
|
||||
print("-"*68)
|
||||
print("Python modules loaded from", os.path.dirname(Image.__file__))
|
||||
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
|
||||
print("-"*68)
|
||||
check_module("PIL CORE", "_imaging")
|
||||
check_module("TKINTER", "_imagingtk")
|
||||
check_codec("JPEG", "jpeg")
|
||||
check_codec("ZLIB (PNG/ZIP)", "zip")
|
||||
check_module("FREETYPE2", "_imagingft")
|
||||
check_module("LITTLECMS", "_imagingcms")
|
||||
print "-"*68
|
||||
print("-"*68)
|
||||
|
||||
# use doctest to make sure the test program behaves as documented!
|
||||
import doctest, selftest
|
||||
print "Running selftest:"
|
||||
print("Running selftest:")
|
||||
status = doctest.testmod(selftest)
|
||||
if status[0]:
|
||||
print "*** %s tests of %d failed." % status
|
||||
print("*** %s tests of %d failed." % status)
|
||||
exit_status = 1
|
||||
else:
|
||||
print "--- %s tests passed." % status[1]
|
||||
print("--- %s tests passed." % status[1])
|
||||
|
||||
sys.exit(exit_status)
|
||||
|
|
6
setup.py
6
setup.py
|
@ -462,6 +462,12 @@ setup(
|
|||
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
|
||||
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
||||
"Topic :: Multimedia :: Graphics :: Viewers",
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 2.6",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.2",
|
||||
"Programming Language :: Python :: 3.3",
|
||||
],
|
||||
cmdclass={"build_ext": pil_build_ext},
|
||||
ext_modules=[Extension("_imaging", ["_imaging.c"])],
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -4,19 +4,8 @@
|
|||
# and then run "tox" from this directory.
|
||||
|
||||
[tox]
|
||||
envlist = py25, py26, py27, py32, pypy
|
||||
envlist = py26, py27, py32, py33, pypy
|
||||
|
||||
[testenv]
|
||||
commands =
|
||||
{envpython} setup.py clean
|
||||
rm -rf build dist
|
||||
{envpython} setup.py install
|
||||
{envpython} selftest.py
|
||||
|
||||
[testenv:py32]
|
||||
commands =
|
||||
{envpython} setup.py clean
|
||||
rm -rf build dist
|
||||
{envpython} setup.py install
|
||||
2to3 -w -n -o . --add-suffix=3 selftest.py
|
||||
{envpython} selftest.py3
|
||||
|
|
Loading…
Reference in New Issue
Block a user