.travis.yml: Run addon tests also with Python 3 (#2185)

Python 3 does not search parent directories of the initially executed
script for modules imported by modules in this parent directory by
default. So simply set the PYTHONPATH to the ./addons directory. Thus
all scripts are found. It is similar to running the test-*.py script
from the ./addons directory, but this way all the paths in the test-*.py
scripts do not have to be changed (for example to find the cppcheck
executable.
For more details regarding the parent directory issue see for example:
https://stackoverflow.com/questions/11393492/python-package-import-from-parent-directory
For details about the used PYTHONPATH solution see:
https://stackoverflow.com/questions/4580101/python-add-pythonpath-during-command-line-module-run
This commit is contained in:
Sebastian 2019-09-19 20:46:16 +02:00 committed by GitHub
parent de9f489b08
commit 7d26a694da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -18,11 +18,14 @@ env:
before_install: before_install:
# install needed deps # install needed deps
- travis_retry sudo apt-get update -qq - travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 libcairo2-dev - travis_retry sudo apt-get install -qq python-pygments python3-pip qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet python3-dev liblua5.3-dev libcurl3 libcairo2-dev
# Python 2 modules
- travis_retry python2 -m pip install --user pytest==4.6.4 - travis_retry python2 -m pip install --user pytest==4.6.4
- travis_retry python2 -m pip install --user pylint - travis_retry python2 -m pip install --user pylint
- travis_retry python2 -m pip install --user unittest2 - travis_retry python2 -m pip install --user unittest2
- travis_retry python2 -m pip install --user pexpect - travis_retry python2 -m pip install --user pexpect
# Python 3 modules
- travis_retry python3 -m pip install --user pytest
matrix: matrix:
# do notify immediately about it when a job of a build fails. # do notify immediately about it when a job of a build fails.
@ -224,6 +227,7 @@ script:
- cd - - cd -
# Testing addons # Testing addons
- python -m pytest addons/test/test-*.py - python -m pytest addons/test/test-*.py
- PYTHONPATH=./addons python3 -m pytest addons/test/test-*.py
notifications: notifications:
irc: irc: