How to run Tox with Travis-CI

前端 未结 4 1496
情话喂你
情话喂你 2021-02-01 03:45

How do you test different Python versions with Tox from within Travis-CI?

I have a tox.ini:

[tox]
envlist = py{27,33,34,35}
recreate = True
         


        
4条回答
  •  情歌与酒
    2021-02-01 04:39

    Travis provides the python version for each test as TRAVIS_PYTHON_VERSION, but in the form '3.4', while tox expects 'py34'.

    If you don't want to rely on an external lib (tox-travis) to do the translation, you can do that manually:

    language: python
    python:
    -   "2.7"
    -   "3.3"
    -   "3.4"
    -   "3.5"
    install:
    -   pip install tox
    script:
    -   tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d .)
    

    Search this pattern in a search engine and you'll find many projects using it.

    This works for pypy as well:

    tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d . | sed -e 's/pypypy/pypy/')
    

    Source: flask-mongoengine's .travis.yml.

提交回复
热议问题