mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #4173 from hugovk/cover-tests
Include tests in coverage reports
This commit is contained in:
commit
4551d3aeb3
|
@ -80,7 +80,7 @@ test_script:
|
|||
- cd c:\pillow
|
||||
- '%PYTHON%\%PIP_DIR%\pip.exe install pytest pytest-cov'
|
||||
- c:\"Program Files (x86)"\"Windows Kits"\10\Debuggers\x86\gflags.exe /p /enable %PYTHON%\%EXECUTABLE%
|
||||
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests'
|
||||
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests'
|
||||
#- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' TODO TEST_OPTIONS with pytest?
|
||||
|
||||
after_test:
|
||||
|
|
|
@ -9,3 +9,10 @@ codecov:
|
|||
token: 6dafc396-e7f5-4221-a38a-8b07a49fbdae
|
||||
|
||||
comment: off
|
||||
|
||||
# Matches 'omit:' in .coveragerc
|
||||
ignore:
|
||||
- "Tests/32bit_segfault_check.py"
|
||||
- "Tests/bench_cffi_access.py"
|
||||
- "Tests/check_*.py"
|
||||
- "Tests/createfontdatachunk.py"
|
||||
|
|
|
@ -12,3 +12,10 @@ exclude_lines =
|
|||
# Don't complain about debug code
|
||||
if Image.DEBUG:
|
||||
if DEBUG:
|
||||
|
||||
[run]
|
||||
omit =
|
||||
Tests/32bit_segfault_check.py
|
||||
Tests/bench_cffi_access.py
|
||||
Tests/check_*.py
|
||||
Tests/createfontdatachunk.py
|
||||
|
|
2
.github/workflows/test-windows.yml
vendored
2
.github/workflows/test-windows.yml
vendored
|
@ -351,7 +351,7 @@ jobs:
|
|||
rem Add libraqm.dll (copied to INCLIB) to PATH.
|
||||
path %INCLIB%;%PATH%
|
||||
cd /D %GITHUB_WORKSPACE%
|
||||
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov-report term --cov-report xml Tests
|
||||
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
|
||||
shell: cmd
|
||||
|
||||
- name: Upload errors
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
python -m pytest -v -x --cov PIL --cov-report term Tests
|
||||
python -m pytest -v -x --cov PIL --cov Tests --cov-report term Tests
|
||||
|
||||
# Docs
|
||||
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then make doccheck; fi
|
||||
|
|
|
@ -27,6 +27,6 @@ Run all the tests from the root of the Pillow source distribution::
|
|||
|
||||
Or with coverage::
|
||||
|
||||
pytest --cov PIL --cov-report term
|
||||
pytest --cov PIL --cov Tests --cov-report term
|
||||
coverage html
|
||||
open htmlcov/index.html
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import sys
|
||||
import timeit
|
||||
|
||||
from . import helper
|
||||
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
|
||||
def bench(mode):
|
||||
im = helper.hopper(mode)
|
||||
get = im.im.getpixel
|
||||
xy = 50, 50 # position shouldn't really matter
|
||||
t0 = timeit.default_timer()
|
||||
for _ in range(1000000):
|
||||
get(xy)
|
||||
print(mode, timeit.default_timer() - t0, "us")
|
||||
|
||||
|
||||
bench("L")
|
||||
bench("I")
|
||||
bench("I;16")
|
||||
bench("F")
|
||||
bench("RGB")
|
|
@ -1,14 +0,0 @@
|
|||
import glob
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
for file in glob.glob("src/PIL/*.py"):
|
||||
module = os.path.basename(file)[:-3]
|
||||
try:
|
||||
exec("from PIL import " + module)
|
||||
except (ImportError, SyntaxError):
|
||||
print("===", "failed to import", module)
|
||||
traceback.print_exc()
|
|
@ -1,66 +0,0 @@
|
|||
# brute-force search for access descriptor hash table
|
||||
|
||||
modes = [
|
||||
"1",
|
||||
"L",
|
||||
"LA",
|
||||
"La",
|
||||
"I",
|
||||
"I;16",
|
||||
"I;16L",
|
||||
"I;16B",
|
||||
"I;32L",
|
||||
"I;32B",
|
||||
"F",
|
||||
"P",
|
||||
"PA",
|
||||
"RGB",
|
||||
"RGBA",
|
||||
"RGBa",
|
||||
"RGBX",
|
||||
"CMYK",
|
||||
"YCbCr",
|
||||
"LAB",
|
||||
"HSV",
|
||||
]
|
||||
|
||||
|
||||
def hash(s, i):
|
||||
# djb2 hash: multiply by 33 and xor character
|
||||
for c in s:
|
||||
i = (((i << 5) + i) ^ ord(c)) & 0xFFFFFFFF
|
||||
return i
|
||||
|
||||
|
||||
def check(size, i0):
|
||||
h = [None] * size
|
||||
for m in modes:
|
||||
i = hash(m, i0)
|
||||
i = i % size
|
||||
if h[i]:
|
||||
return 0
|
||||
h[i] = m
|
||||
return h
|
||||
|
||||
|
||||
min_start = 0
|
||||
|
||||
# 1) find the smallest table size with no collisions
|
||||
for min_size in range(len(modes), 16384):
|
||||
if check(min_size, 0):
|
||||
print(len(modes), "modes fit in", min_size, "slots")
|
||||
break
|
||||
|
||||
# 2) see if we can do better with a different initial value
|
||||
for i0 in range(65556):
|
||||
for size in range(1, min_size):
|
||||
if check(size, i0):
|
||||
if size < min_size:
|
||||
print(len(modes), "modes fit in", size, "slots with start", i0)
|
||||
min_size = size
|
||||
min_start = i0
|
||||
|
||||
print()
|
||||
|
||||
print("#define ACCESS_TABLE_SIZE", min_size)
|
||||
print("#define ACCESS_TABLE_HASH", min_start)
|
|
@ -1,57 +0,0 @@
|
|||
import io
|
||||
import queue
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
|
||||
test_format = sys.argv[1] if len(sys.argv) > 1 else "PNG"
|
||||
|
||||
im = Image.open("Tests/images/hopper.ppm")
|
||||
im.load()
|
||||
|
||||
queue = queue.Queue()
|
||||
|
||||
result = []
|
||||
|
||||
|
||||
class Worker(threading.Thread):
|
||||
def run(self):
|
||||
while True:
|
||||
im = queue.get()
|
||||
if im is None:
|
||||
queue.task_done()
|
||||
sys.stdout.write("x")
|
||||
break
|
||||
f = io.BytesIO()
|
||||
im.save(f, test_format, optimize=1)
|
||||
data = f.getvalue()
|
||||
result.append(len(data))
|
||||
im = Image.open(io.BytesIO(data))
|
||||
im.load()
|
||||
sys.stdout.write(".")
|
||||
queue.task_done()
|
||||
|
||||
|
||||
t0 = time.time()
|
||||
|
||||
threads = 20
|
||||
jobs = 100
|
||||
|
||||
for i in range(threads):
|
||||
w = Worker()
|
||||
w.start()
|
||||
|
||||
for i in range(jobs):
|
||||
queue.put(im)
|
||||
|
||||
for i in range(threads):
|
||||
queue.put(None)
|
||||
|
||||
queue.join()
|
||||
|
||||
print()
|
||||
print(time.time() - t0)
|
||||
print(len(result), sum(result))
|
||||
print(result)
|
|
@ -1,26 +0,0 @@
|
|||
from PIL import Image
|
||||
|
||||
|
||||
def version(module, version):
|
||||
v = getattr(module.core, version + "_version", None)
|
||||
if v:
|
||||
print(version, v)
|
||||
|
||||
|
||||
version(Image, "jpeglib")
|
||||
version(Image, "zlib")
|
||||
version(Image, "libtiff")
|
||||
|
||||
try:
|
||||
from PIL import ImageFont
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
version(ImageFont, "freetype2")
|
||||
|
||||
try:
|
||||
from PIL import ImageCms
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
version(ImageCms, "littlecms")
|
Loading…
Reference in New Issue
Block a user