Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Testing python 2.6, 2.7, and 3.2 #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 27, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Editor temporary/working/backup files #
#########################################
# Editor temporary/working/backup files #
.#*
[#]*#
*~
Expand Down Expand Up @@ -27,6 +27,8 @@ doc/_build
dist
# Egg metadata
*.egg-info
# tox testing tool
.tox

# OS generated files #
######################
Expand Down
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: python

python:
- 2.6
- 2.7
- 3.1
- 3.2

install:
- pip install --use-mirrors nose numpy
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip install --use-mirrors PIL; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are my biggest concern. Presumably this is so that the CI server has the appropriate setup, but what happens is PIL & numpy already exist on the server?

Can you easily test with different versions of numpy?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install doesn't reinstall packages without the --upgrade option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have enough exposure to pip to have confidence, so thanks for the clarification.

Note: For clarification, I read what you said to mean "even if the original install wasn't done by pip, no re-installation will be done".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -- that's my understanding of how it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is for Travis and Travis starts with a completely clean environment every time it runs. Basically you have a fresh new VirtualBox VM sandbox for each build.

- python setup.py install

script:
- mkdir ../foo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could have a better folder name. Presumably this is done to have somewhere to store the result images?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, that foo folder is simply so that we're not in the source directory because then Python 3 will import modules from there which have not been transformed by 2to3. Will definitely take ideas for better folder names or a better approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So pwd is the root of the repository, but if your in the root of the repository, when importing matplotlib via python3, you would actually be importing the source rather than the built version?
Perhaps it would be better to run python setup.py build which will make a clean build/lib* directory, or is it advised by travis to actually install the code that is being tested?

At the very least, this mkdir should have a comment to explain the reasoning, and perhaps rename the folder to test_results (I don't have much feeling for a good folder name either).

- cd ../foo
- python ../matplotlib/tests.py
66 changes: 66 additions & 0 deletions doc/devel/coding_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,72 @@ Let's say you've added a new module named
the list of default tests, append its name to ``default_test_modules``
in :file:`lib/matplotlib/__init__.py`.

Using tox
---------

`Tox <http://tox.testrun.org/>`_ is a tool for running tests against multiple
Python environments, including multiple versions of Python (e.g.: 2.6, 2.7,
3.2, etc.) and even different Python implementations altogether (e.g.: CPython,
PyPy, Jython, etc.)

Testing all 4 versions of Python (2.6, 2.7, 3.1, and 3.2) requires having four
versions of Python installed on your system and on the PATH. Depending on your
operating system, you may want to use your package manager (such as apt-get,
yum or MacPorts) to do this, or use `pythonbrew
<https://github.com/utahta/pythonbrew>`_.

tox makes it easy to determine if your working copy introduced any regressions
before submitting a pull request. Here's how to use it:

.. code-block:: bash

$ pip install tox
$ tox

You can also run tox on a subset of environments:

.. code-block:: bash

$ tox -e py26,py27

Tox processes everything serially so it can take a long time to test several
environments. To speed it up, you might try using a new, parallelized version
of tox called ``detox``. Give this a try:

.. code-block:: bash

$ pip install -U -i http://pypi.testrun.org detox
$ detox

Tox is configured using a file called ``tox.ini``. You may need to edit this
file if you want to add new environments to test (e.g.: ``py33``) or if you
want to tweak the dependencies or the way the tests are run. For more info on
the ``tox.ini`` file, see the `Tox Configuration Specification
<http://tox.testrun.org/latest/config.html>`_.

Using Travis CI
---------------

`Travis CI <http://travis-ci.org/>`_ is a hosted CI system "in the cloud".

Travis is configured to receive notifications of new commits to GitHub repos
(via GitHub "service hooks") and to run builds or tests when it sees these new
commits. It looks for a YAML file called ``.travis.yml`` in the root of the
repository to see how to test the project.

Travis CI is already enabled for the `main matplotlib GitHub repository
<https://github.com/matplotlib/matplotlib/>`_ -- for example, see `its Travis
page <http://travis-ci.org/#!/matplotlib/matplotlib>`_.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still actually need to add the service hook, correct? You're just writing this from the point of view of after this PR is merged and the service hook has been added, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Exactly.

If you want to enable Travis CI for your personal matplotlib GitHub repo,
simply enable the repo to use Travis CI in either the Travis CI UI or the
GitHub UI (Admin | Service Hooks). For details, see `the Travis CI Getting
Started page <http://about.travis-ci.org/docs/user/getting-started/>`_.

Once this is configured, you can see the Travis CI results at
http://travis-ci.org/#!/your_GitHub_user_name/matplotlib -- here's `an example
<http://travis-ci.org/#!/msabramo/matplotlib>`_.

.. _license-discussion:

Licenses
Expand Down
16 changes: 16 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, py31, py32

[testenv]
changedir = /tmp
commands =
sh -c 'rm -f $HOME/.matplotlib/fontList*'
{envpython} {toxinidir}/tests.py
deps =
nose
numpy