Test with coverage on Windows, update 'setup.py test'

This commit is contained in:
Hugo 2017-10-29 15:11:00 +02:00 committed by wiredfool
parent db760c1284
commit 3515ae3d9e
9 changed files with 36 additions and 17 deletions

9
.gitignore vendored
View File

@ -6,6 +6,7 @@ __pycache__/
*.so *.so
# Distribution / packaging # Distribution / packaging
.eggs/
.Python .Python
env/ env/
bin/ bin/
@ -69,3 +70,11 @@ docs/_build/
#OS #OS
.DS_Store .DS_Store
# JetBrains
.idea
# Extra test images installed from pillow-depends/test_images
Tests/images/README.md
Tests/images/msp
Tests/images/picins
Tests/images/sunraster

View File

@ -7,12 +7,12 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-tk\
python-qt4 ghostscript libffi-dev libjpeg-turbo-progs cmake imagemagick\ python-qt4 ghostscript libffi-dev libjpeg-turbo-progs cmake imagemagick\
libharfbuzz-dev libfribidi-dev libharfbuzz-dev libfribidi-dev
pip install check-manifest
pip install cffi pip install cffi
pip install check-manifest
pip install coverage pip install coverage
pip install olefile pip install olefile
pip install pytest pip install -U pytest
pip install pytest-cov pip install -U pytest-cov
pip install pyroma pip install pyroma
pip install test-image-results pip install test-image-results

View File

@ -6,8 +6,8 @@ coverage erase
python setup.py clean python setup.py clean
CFLAGS="-coverage" python setup.py build_ext --inplace CFLAGS="-coverage" python setup.py build_ext --inplace
coverage run --append --include="PIL/*" selftest.py python selftest.py
python -m pytest -vx --cov PIL --cov-append --cov-report term Tests python setup.py test
pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd
# Docs # Docs

View File

@ -15,12 +15,9 @@ co:
done done
coverage: coverage:
coverage erase python selftest.py
coverage run --parallel-mode --include=PIL/* selftest.py python setup.py test
python -m pytest --cov PIL --cov-append --cov-report html Tests
# Doesn't combine properly before report, writing report instead of displaying invalid report.
rm -r htmlcov || true rm -r htmlcov || true
coverage combine
coverage report coverage report
doc: doc:

View File

@ -74,8 +74,13 @@ build_script:
test_script: test_script:
- cd c:\pillow - cd c:\pillow
- '%PYTHON%\%PIP_DIR%\pip.exe install nose' - '%PYTHON%\%PIP_DIR%\pip.exe install pytest pytest-cov'
- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' - '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --cov-append --cov-report term --cov-report xml Tests'
#- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%' TODO TEST_OPTIONS with pytest?
after_test:
- pip install codecov
- codecov --file coverage.xml --name %PYTHON%
matrix: matrix:
fast_finish: true fast_finish: true

View File

@ -1,2 +1,6 @@
[aliases]
test=pytest
[metadata] [metadata]
license_file = LICENSE license_file = LICENSE
[tool:pytest]
addopts = -vx --cov PIL --cov-append --cov-report term Tests

View File

@ -751,6 +751,9 @@ def debug_build():
return hasattr(sys, 'gettotalrefcount') return hasattr(sys, 'gettotalrefcount')
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
try: try:
setup(name=NAME, setup(name=NAME,
version=PILLOW_VERSION, version=PILLOW_VERSION,
@ -782,7 +785,8 @@ try:
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])], ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
include_package_data=True, include_package_data=True,
packages=find_packages(), packages=find_packages(),
test_suite='nose.collector', setup_requires=pytest_runner,
tests_require=['pytest'],
keywords=["Imaging", ], keywords=["Imaging", ],
license='Standard PIL License', license='Standard PIL License',
zip_safe=not (debug_build() or PLATFORM_MINGW), ) zip_safe=not (debug_build() or PLATFORM_MINGW), )

View File

@ -7,5 +7,5 @@ pacman -S --noconfirm mingw32/mingw-w64-i686-python3 \
mingw32/mingw-w64-i686-python2-setuptools \ mingw32/mingw-w64-i686-python2-setuptools \
mingw-w64-i686-libjpeg-turbo mingw-w64-i686-libjpeg-turbo
/mingw32/bin/pip install nose olefile /mingw32/bin/pip install pytest pytest-cov olefile
/mingw32/bin/pip3 install nose olefile /mingw32/bin/pip3 install pytest pytest-cov olefile

View File

@ -16,7 +16,7 @@ def setup_vms():
for arch in ('', X64_EXT): for arch in ('', X64_EXT):
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s" ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
% (py, arch, VIRT_BASE, py, arch)) % (py, arch, VIRT_BASE, py, arch))
ret.append(r"%s%s%s\Scripts\pip.exe install nose" % ret.append(r"%s%s%s\Scripts\pip.exe install pytest pytest-cov" %
(VIRT_BASE, py, arch)) (VIRT_BASE, py, arch))
return "\n".join(ret) return "\n".join(ret)
@ -76,7 +76,7 @@ def build_one(py_ver, compiler):
args['executable'] = "python.exe" args['executable'] = "python.exe"
if 'EXECUTABLE' in os.environ: if 'EXECUTABLE' in os.environ:
args['executable'] = "%EXECUTABLE%" args['executable'] = "%EXECUTABLE%"
args['py_ver'] = py_ver args['py_ver'] = py_ver
if '34' in py_ver: if '34' in py_ver:
args['tcl_ver'] = '86' args['tcl_ver'] = '86'