简体   繁体   中英

Make Travis-CI run *both* Python 2 and 3

Should hopefully be a pretty basic question, but here is my .travis.yml file below:

language: python

python:
    - "2.6"
    - "2.7"
    - "3.2"
    - "3.3"
    - "3.4"
    - "3.5"
    - "nightly"

matrix:
  allow_failures:
    - python: "2.6"
    - python: "3.2"
    - python: "3.3"
    - python: "3.4"
    - python: "nightly"

install:
    - pip install -r requirements.pip
    - pip install -r test/requirements.pip

script: python -B test/test.py

If you look at the script at the bottom, it's the Python 2 command, whereas python3 is for Python 3. As you can see up top, I choose to use versions from both Python 2 and 3.

I want to ask, will that bottom script argument suffice? I want Travis to run my script on every single version that I chose above.

I also chose to ask before just uploading it and trying, because I just want to upload the .yml and have it work on the spot. Without making several commits trying to cleanup small errors and putting build-fails everywhere.

Yes. python can be pointing to any version of Python, and in fact it defaults to 3 in some distros like Arch. virtualenv which Travis uses links python to the specified version.

Debugging tips: if you want to avoid polluting commit history, create a branch to work on it and squash/rebase merge later.

The command python will always mean one of the Python versions from the matrix; ie your build will be executed 5 times, each time python pointing a different version from that list.

The version number for the current sub-build available in the TRAVIS_PYTHON_VERSION environment variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM