I’m in a rather awkward situation where my application is written in Python 3 but the script that mocks some testing data depends on Python 2. Unfortunately, migrating to Python 3 is no small task and I won’t be able to make the time to do it for a while. Is there a way to use both Python versions within my tests?
There are a few options to achieve that, you can find the examples right here.
You should be able to reference explicit versions of Python in your tests by using
python2.7 instead of
python which will run the specific version of Python instead of the symlinked default version.
When I run
python2.7, I get the following error:
python2.7 db/generate.py user=ubuntu dbname=circle_test
pyenv: python2.7: command not found
The `python2.7' command exists in these Python versions:
Choosing one of those versions results in:
python2.7.10 db/generate.py user=ubuntu dbname=circle_test returned exit code 127
bash: line 1: python2.7.10: command not found Action failed: python2.7.10 db/generate.py user=ubuntu dbname=circle_test
ugh, it’s only letting you pick from the python binaries that are in the pyenv configuration.
I know that python 2.7.* is installed within the pyenv environment but the question is how do we get your current shell to let you break out of the pyenv sandbox and run the version you specify.
I’m going to ping the other support folks to talk about this.
I’m dealing with a similar situation. Has a solution been found for this?
A method I’ve started to use is to put into the
pre section the
pyenv install #.#.# steps for what I want to use and then have a
pyenv global #.#.# #.#.# that lists them all
You can see this in action here https://github.com/bear/parsedatetime/blob/master/circle.yml
It seems one of our other community members has run into this very issue and has written a blog post about it - you should check it out – https://ben.fogbutter.com/2016/02/20/testing-multiple-python-versions-on-circleci.html