Skip to content

Small python project example with tox, pyenv and pytest.

Notifications You must be signed in to change notification settings

ferencberes/tox-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tox-example

Small python project example with tox, pyenv and pytest.

Information

In this repository there is an implementation of weighted indegree for directed graphs based on NetworkX, which will be tested by pytest in multiple pyenv environments.

Prerequisites

  1. install python 2.7.9 and 2.7.10:
pyenv install 2.7.9
pyenv install 2.7.10
  1. create two new virtualenvs with names tox_example_env and tox_2-7-10:
pyenv virtualenv 2.7.9 tox_example_env
pyenv virtualenv 2.7.10 tox_2-7-10
pyenv virtualenvs
  1. install tox and tox-pyenv in both environments:
pyenv activate tox_example_env
pip install tox tox-pyenv
pyenv activate tox_2-7-10
pip install tox tox-pyenv
pyenv deactivate
  1. After cloning the repository set tox_example_env and tox_2-7-10 as local pyenv environments:
cd tox-example
pyenv local tox_example_env tox_2-7-10

Dependencies and testing

a.) Install with pip manually

  • These python modules have to be installed in both environments:
pyenv activate tox_example_env
pip install networkx numpy pytest
pyenv activate tox_2-7-10
pip install networkx numpy pytest
pyenv deactivate   

Especially pytest, otherwise py.test command will call for pytest installed in an other environment!

[tox]
envlist = tox_example_env,tox_2-7-10
[testenv]
commands = py.test
  • Then you can run tests:

By pytest : It will work only with a selected pyenv environment:

cd tox-example
pyenv activate tox_example_env
py.test
pyenv activate tox_2-7-10
py.test
pyenv deactivate 

By tox : It can handle run tests for multiple pyenv environments as well

cd tox-example
tox

In this case, you will get WARNINGS because there was no deps key specified under [testenv] in the tox.ini file.

b.) Install with tox automatically

[tox]
envlist = tox_example_env,tox_2-7-10
[testenv]
deps =
    pytest
    numpy
    networkx
commands = py.test
  • With the above file tox install all modules automatically when we run the following command:
cd tox-example
tox

About

Small python project example with tox, pyenv and pytest.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages