diff --git a/.appveyor.yml b/.appveyor.yml index a7e40f560..c7e158742 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,49 +1,37 @@ environment: - global: - # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the - # /E:ON and /V:ON options are not enabled in the batch script intepreter - # See: http://stackoverflow.com/a/13751649/163740 - CMD_IN_ENV: "cmd /E:ON /V:ON /C run_with_env.cmd" - # links to python-appveyor-demo's scripts by Olivier Grisel's (@ogrisel): - RUN_WITH_ENV_CMD_URL: "https://raw.githubusercontent.com/ogrisel/python-appveyor-demo/master/appveyor/run_with_env.cmd" - INSTALL_PS1_URL: "https://raw.githubusercontent.com/ogrisel/python-appveyor-demo/master/appveyor/install.ps1" - matrix: - PYTHON: "C:\\Python27" PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "32" + TOXENV: "py27" - PYTHON: "C:\\Python34" PYTHON_VERSION: "3.4.x" PYTHON_ARCH: "32" + TOXENV: "py34" - PYTHON: "C:\\Python35" - PYTHON_VERSION: "3.5.0" + PYTHON_VERSION: "3.5.x" PYTHON_ARCH: "32" + TOXENV: "py35" - PYTHON: "C:\\Python27-x64" PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "64" + TOXENV: "py27" - PYTHON: "C:\\Python34-x64" PYTHON_VERSION: "3.4.x" PYTHON_ARCH: "64" + TOXENV: "py34" - PYTHON: "C:\\Python35-x64" - PYTHON_VERSION: "3.5.0" + PYTHON_VERSION: "3.5.x" PYTHON_ARCH: "64" + TOXENV: "py35" install: - # download 'run_with_env.cmd' script that configures environment variables for the - # MSVC compiler and Windows SDK versions. - - "appveyor DownloadFile %RUN_WITH_ENV_CMD_URL%" - - # download 'install.ps1' to install Python (official .msi of http://python.org) and - # pip when not already installed - - "appveyor DownloadFile %INSTALL_PS1_URL%" - - ps: if (-not(Test-Path($env:PYTHON))) { & install.ps1 } - - # Prepend newly installed Python to the PATH of this build + # Prepend Python to the PATH of this build - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" # check that we have the expected version and architecture for Python @@ -53,23 +41,17 @@ install: # upgrade pip to avoid out-of-date warnings - "pip install --disable-pip-version-check --user --upgrade pip" - # Install the build dependencies of the project. If some dependencies contain - # compiled extensions and are not provided as pre-built wheel packages, - # pip will build them from source using the MSVC compiler matching the - # target Python version and architecture - - "%CMD_IN_ENV% pip install -vr requirements.txt" + # install the dependencies to run the tests + - "pip install -r dev-requirements.txt" build: false test_script: - - "SET PATH=C:\\msys64\\usr\\bin;%PATH%" - # 'run-test.sh' interprets $PYTHON as the executable name - - "SET PYTHON=python" - - "bash run-tests.sh" + - "tox" after_test: # if tests are successful, create packages for the project - - "%CMD_IN_ENV% python setup.py sdist --formats=zip" + - python setup.py sdist --formats=zip" artifacts: # archive the generated packages in the ci.appveyor.com build report diff --git a/.travis/install.sh b/.travis/install.sh index ec511296c..0c2a1104e 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -51,4 +51,4 @@ fi python -m virtualenv ~/.venv source ~/.venv/bin/activate -pip install tox +pip install -r dev-requirements.txt diff --git a/Lib/fontTools/misc/loggingTools.py b/Lib/fontTools/misc/loggingTools.py index f2a302ea7..7295c5520 100644 --- a/Lib/fontTools/misc/loggingTools.py +++ b/Lib/fontTools/misc/loggingTools.py @@ -229,19 +229,19 @@ class Timer(object): >>> timer = Timer() >>> time.sleep(0.01) >>> print("First lap:", timer.split()) - First lap: 0.0... + First lap: ... >>> time.sleep(0.02) >>> print("Second lap:", timer.split()) - Second lap: 0.0... + Second lap: ... >>> print("Overall time:", timer.time()) - Overall time: 0.0... + Overall time: ... Can be used as a context manager inside with-statements. >>> with Timer() as t: ... time.sleep(0.01) >>> print("%0.3f seconds" % t.elapsed) - 0.0... seconds + 0... seconds If initialised with a logger, it can log the elapsed time automatically upon exiting the with-statement. @@ -259,7 +259,7 @@ class Timer(object): >>> timer = Timer(log) >>> with timer(): ... time.sleep(0.01) - elapsed time: 0.01...s + elapsed time: ...s >>> with timer('redo it', level=logging.INFO): ... time.sleep(0.02) Took ... to redo it @@ -274,7 +274,7 @@ class Timer(object): ... def test2(): ... time.sleep(0.02) >>> test1() - Took 0.01... to run 'test1' + Took ... to run 'test1' >>> test2() Took ... to run test 2 """ diff --git a/Lib/fontTools/misc/py23_test.py b/Lib/fontTools/misc/py23_test.py index 867945f01..b535e7373 100644 --- a/Lib/fontTools/misc/py23_test.py +++ b/Lib/fontTools/misc/py23_test.py @@ -36,8 +36,11 @@ class OpenFuncWrapperTest(unittest.TestCase): try: with open(datafile, 'rb') as infile, \ tempfile.NamedTemporaryFile(delete=False) as outfile: + env = dict(os.environ) + env["PYTHONPATH"] = os.pathsep.join(sys.path) check_call( - [sys.executable, script], stdin=infile, stdout=outfile) + [sys.executable, script], stdin=infile, stdout=outfile, + env=env) result = not filecmp.cmp(infile.name, outfile.name, shallow=False) finally: os.remove(script) diff --git a/Lib/fontTools/ttLib/woff2_test.py b/Lib/fontTools/ttLib/woff2_test.py index ca4282bf6..8996ed8f0 100644 --- a/Lib/fontTools/ttLib/woff2_test.py +++ b/Lib/fontTools/ttLib/woff2_test.py @@ -7,7 +7,7 @@ from .woff2 import (WOFF2Reader, woff2DirectorySize, woff2DirectoryFormat, WOFF2FlavorData, woff2TransformedTableTags, WOFF2GlyfTable, WOFF2LocaTable, WOFF2Writer) import unittest -import sstruct +from fontTools.misc import sstruct import os import random import copy diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 000000000..18e00b343 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,2 @@ +pytest>=2.8 +tox>=2.3 diff --git a/requirements.txt b/requirements.txt index 2d7a35b5a..c0d1e9138 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -git+https://github.com/google/brotli@66db08156eba94f1fb0f77b6af519e4adedea8bf#egg=Brotli \ No newline at end of file +git+https://github.com/google/brotli@v0.3.0#egg=Brotli \ No newline at end of file diff --git a/run-tests.sh b/run-tests.sh index e97e9c3f5..662d19aef 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -12,46 +12,17 @@ elif test "x$1" = x-2; then shift fi test "x$PYTHON" = x && PYTHON=python -echo "$(which $PYTHON) --version" -$PYTHON --version 2>&1 -echo - -# Setup environment -DIR=`dirname "$0"` -cd "$DIR/Lib" -if [ "x$PYTHONPATH" != "x" ]; then - PYTHONPATH=".:$PYTHONPATH" -else - PYTHONPATH="." -fi -export PYTHONPATH # Find tests -FILTER= +FILTERS= for arg in "$@"; do - test "x$FILTER" != x && FILTER="$FILTER|" - FILTER="$FILTER$arg" + test "x$FILTERS" != x && FILTERS="$FILTERS or " + FILTERS="$FILTERS$arg" done -test "x$FILTER" = "x" && FILTER=. -TESTS=`grep -r --include='*.py' -l -e doctest -e unittest * | grep -E "$FILTER"` - -ret=0 -FAILS= -for test in $TESTS; do - echo "Running tests in $test" - test=`echo "$test" | sed 's@[/\\]@.@g;s@[.]py$@@'` - if ! $PYTHON -m $test -v; then - ret=$((ret+1)) - FAILS="$FAILS -$test" - fi -done - echo - echo "SUMMARY:" -if test $ret = 0; then - echo "All tests passed." +# Run tests +if [ -z "$FILTERS" ]; then + $PYTHON -m pytest else - echo "$ret source file(s) had tests failing:$FAILS" >&2 + $PYTHON -m pytest -k "$FILTERS" fi -exit $ret diff --git a/tox.ini b/tox.ini index f977b8e2b..a4d0dd64e 100644 --- a/tox.ini +++ b/tox.ini @@ -9,8 +9,11 @@ commands = py.test [pytest] +minversion = 2.8 testpaths = Lib/fontTools +python_files = + *_test.py addopts = # run py.test in verbose mode -v