Skip to content

Commit

Permalink
Merge cecd7dd into 7afaf4d
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Nov 6, 2017
2 parents 7afaf4d + cecd7dd commit c211ff2
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 53 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __pycache__/
*.so

# Distribution / packaging
.eggs/
.Python
env/
bin/
Expand Down Expand Up @@ -69,3 +70,11 @@ docs/_build/
#OS
.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
5 changes: 3 additions & 2 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-tk\
libharfbuzz-dev libfribidi-dev

pip install cffi
pip install nose
pip install check-manifest
pip install coverage
pip install olefile
pip install -U pytest
pip install -U pytest-cov
pip install pyroma
pip install coverage

# docs only on Python 2.7
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then pip install -r requirements.txt ; fi
Expand Down
4 changes: 2 additions & 2 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ coverage erase
python setup.py clean
CFLAGS="-coverage" python setup.py build_ext --inplace

coverage run --append --include=PIL/* selftest.py
coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py
python selftest.py
python setup.py test
pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd

# Docs
Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ co:
done

coverage:
coverage erase
coverage run --parallel-mode --include=PIL/* selftest.py
nosetests --with-cov --cov='PIL/' --cov-report=html Tests/test_*.py
# Doesn't combine properly before report, writing report instead of displaying invalid report.
python selftest.py
python setup.py test
rm -r htmlcov || true
coverage combine
coverage report

doc:
Expand Down Expand Up @@ -81,7 +78,7 @@ release-test:
$(MAKE) install-req
python setup.py develop
python selftest.py
nosetests Tests/test_*.py
python -m pytest Tests
python setup.py install
python test-installed.py
check-manifest
Expand Down
10 changes: 3 additions & 7 deletions Tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Dependencies

Install::

pip install coverage nose
pip install pytest pytest-cov

Execution
---------
Expand All @@ -21,12 +21,11 @@ To run an individual test::

Run all the tests from the root of the Pillow source distribution::

nosetests -vx Tests/test_*.py
pytest -vx Tests

Or with coverage::

coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py
coverage report
pytest -vx --cov PIL --cov-report term Tests
coverage html
open htmlcov/index.html

Expand All @@ -39,6 +38,3 @@ To run an individual test::
Run all the tests from the root of the Pillow source distribution::

./test-installed.py



11 changes: 6 additions & 5 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def delete_tempfile(self, path):
try:
ok = self.currentResult.wasSuccessful()
except AttributeError: # for nosetests
proxy = self.currentResult
ok = (len(proxy.errors) + len(proxy.failures) == 0)
# proxy = self.currentResult
# ok = (len(proxy.errors) + len(proxy.failures) == 0)
ok = True # TODO pytest

if ok:
# only clean out tempfiles if test passed
Expand Down Expand Up @@ -180,15 +181,15 @@ class PillowLeakTestCase(PillowTestCase):
# requires unix/osx
iterations = 100 # count
mem_limit = 512 # k

def _get_mem_usage(self):
"""
Gets the RUSAGE memory usage, returns in K. Encapsulates the difference
between OSX and Linux rss reporting
:returns; memory usage in kilobytes
"""

from resource import getpagesize, getrusage, RUSAGE_SELF
mem = getrusage(RUSAGE_SELF).ru_maxrss
if sys.platform == 'darwin':
Expand All @@ -199,7 +200,7 @@ def _get_mem_usage(self):
# linux
# man 2 getrusage
# ru_maxrss (since Linux 2.6.32)
# This is the maximum resident set size used (in kilobytes).
# This is the maximum resident set size used (in kilobytes).
return mem # Kb

def _test_leak(self, core):
Expand Down
19 changes: 12 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,35 @@ install:
{
c:\python34\python.exe c:\pillow\winbuild\build_dep.py
c:\pillow\winbuild\build_deps.cmd
$host.SetShouldExit(0)
$host.SetShouldExit(0)
}
build_script:
- ps: |
if ($env:PYTHON -eq "c:/msys64/mingw32")
{
c:\msys64\usr\bin\bash -l -c c:\\pillow\\winbuild\\appveyor_build_msys2.sh
Write-Host "through install"
$host.SetShouldExit(0)
$host.SetShouldExit(0)
}
else
{
& $env:PYTHON/$env:EXECUTABLE c:\pillow\winbuild\build.py
$host.SetShouldExit(0)
$host.SetShouldExit(0)
}
- cd c:\pillow
- mv PIL PIL.temp
- '%PYTHON%\%EXECUTABLE% selftest.py --installed'

test_script:
- cd c:\pillow
- '%PYTHON%\%PIP_DIR%\pip.exe install nose'
- '%PYTHON%\%EXECUTABLE% test-installed.py -v -s %TEST_OPTIONS%'
- '%PYTHON%\%PIP_DIR%\pip.exe install pytest pytest-cov'
- '%PYTHON%\%EXECUTABLE% -m pytest -vx --cov PIL --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:
fast_finish: true
Expand Down Expand Up @@ -107,7 +112,7 @@ deploy:
on:
branch: master
deploy: YES


# Uncomment the following line to get RDP access after the build/test and block for
# up to the timeout limit (~1hr)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ coveralls
docopt
docutils
jarn.viewdoc
nose-cov
nose
pytest
pytest-cov
olefile
pep8
pyflakes
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[aliases]
test=pytest
[metadata]
license_file = LICENSE
[tool:pytest]
addopts = -vx --cov PIL --cov-report term Tests
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RequiredDependencyException(Exception): pass
PLATFORM_MINGW = 'mingw' in ccompiler.get_default_compiler()
PLATFORM_PYPY = hasattr(sys, 'pypy_version_info')


def _dbg(s, tp=None):
if DEBUG:
if tp:
Expand Down Expand Up @@ -750,6 +751,10 @@ def add_multiarch_paths(self):
def debug_build():
return hasattr(sys, 'gettotalrefcount')

needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []


try:
setup(name=NAME,
version=PILLOW_VERSION,
Expand Down Expand Up @@ -780,7 +785,8 @@ def debug_build():
include_package_data=True,
packages=find_packages(),
scripts=glob.glob("Scripts/*.py"),
test_suite='nose.collector',
setup_requires=pytest_runner,
tests_require=['pytest'],
keywords=["Imaging", ],
license='Standard PIL License',
zip_safe=not (debug_build() or PLATFORM_MINGW), )
Expand Down
31 changes: 14 additions & 17 deletions test-installed.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
import nose
import os
import sys
import glob

import pytest

# monkey with the path, removing the local directory but adding the Tests/
# directory for helper.py and the other local imports there.
Expand All @@ -13,23 +13,20 @@
# if there's no test selected (mostly) choose a working default.
# Something is required, because if we import the tests from the local
# directory, once again, we've got the non-installed PIL in the way
for arg in sys.argv[1:]:
if '.py' in arg:
for i, arg in enumerate(sys.argv[1:]):
print(i, arg)
if arg.startswith('Tests/test_') and arg.endswith('.py'):
print("bingo")
sys.argv.insert(i+1, '-k')
break
else:
sys.argv.extend(glob.glob('Tests/test*.py'))

# Make sure that nose doesn't muck with our paths.
if ('--no-path-adjustment' not in sys.argv) and ('-P' not in sys.argv):
sys.argv.insert(1, '--no-path-adjustment')
sys.argv.append('Tests')

if 'NOSE_PROCESSES' not in os.environ:
for arg in sys.argv:
if '--processes' in arg:
break
else: # for
sys.argv.insert(1, '--processes=-1') # -1 == number of cores
sys.argv.insert(1, '--process-timeout=30')
# for arg in sys.argv:
# if '-n' in arg or '--numprocesses' in arg:
# break
# else: # for
# sys.argv.extend(['--numprocesses' ,'auto']) # auto-detect number of CPUs

if __name__ == '__main__':
nose.main()
pytest.main()
4 changes: 2 additions & 2 deletions winbuild/appveyor_install_msys2_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pacman -S --noconfirm mingw32/mingw-w64-i686-python3 \
mingw32/mingw-w64-i686-python2-setuptools \
mingw-w64-i686-libjpeg-turbo

/mingw32/bin/pip install nose olefile
/mingw32/bin/pip3 install nose olefile
/mingw32/bin/pip install pytest pytest-cov olefile
/mingw32/bin/pip3 install pytest pytest-cov olefile
4 changes: 2 additions & 2 deletions winbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup_vms():
for arch in ('', X64_EXT):
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
% (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))
return "\n".join(ret)

Expand Down Expand Up @@ -76,7 +76,7 @@ def build_one(py_ver, compiler):
args['executable'] = "python.exe"
if 'EXECUTABLE' in os.environ:
args['executable'] = "%EXECUTABLE%"

args['py_ver'] = py_ver
if '34' in py_ver:
args['tcl_ver'] = '86'
Expand Down

0 comments on commit c211ff2

Please sign in to comment.