# Testing in different environments

**URL:** <https://discuss.circleci.com/t/testing-in-different-environments/450>\
**Category:** Programming Languages\
**Tags:** multiple-versions, python\
**Created:** [November 10, 2015, 9:17pm UTC](https://discuss.circleci.com/t/testing-in-different-environments/450 "2015-11-10T21:17:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![DevendraMeena1](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/devendrameena1/32/302_2.png) [@DevendraMeena1](https://discuss.circleci.com/u/DevendraMeena1)\
**Post date:** [November 11, 2015, 6:46am UTC](https://discuss.circleci.com/t/testing-in-different-environments/450/2 "2015-11-11T06:46:30Z")

</div>

Tox is a tool for automate testing in Python. It does so by reading  
a tox.ini file where we specify the environments we want to test, and it will create a brand new  
virtual environment for that setup and run the test suite against it.  
Let’s start by installing tox and add it to our requirements.txt file.

(django-foobar):~/django-foobar$ pip install tox  
(django-foobar):~/django-foobar$ echo “tox” \>\> requirements.txt

Create a new file tox.ini in the projects working directory and paste the content below.

[tox]  
envlist =  
py27-django1.6,  
py34-django1.8

[django1.6]  
deps =  
Django\>=1.6,\<1.7

[django1.8]  
deps =  
Django\>=1.8,\<1.9

[testenv]  
commands =  
python {toxinidir}/setup.py test

[testenv:py27-django1.6]  
basepython = python2.7  
deps =  
{[django1.6]deps}

[testenv:py34-django1.8]  
basepython = python3.4  
deps =  
{[django1.8]deps}

As you can see we have a [tox] block in which we defines a list of environments we want to test.  
Next, we define some blocks for the different Django versions we want to test. The [testenv] block  
defines the command we want to run, and finally we combine the [testenv] with the different version  
blocks in order to fire up the test runner.

---

_[View the full topic](https://discuss.circleci.com/t/testing-in-different-environments/450)._
