This would be a good use case for using a Python virtual environment to test your code, see the virtualenv :
http://www.virtualenv.org/en/latest/
You can use the --python
flag to specify a Python version in your virtual environment:
virtualenv --python /path/to/python2.7 env_27