0

I have following in my tox.ini :

[tox]
skipsdist = true
envlist = py27, py36, lint

[testenv]
whitelist_externals=flake8
commands =
    version: python setup.py --version

When I run

tox -e version

I get the following output :

tox -e version 2>version
version runtests: PYTHONHASHSEED='3264081464'
version runtests: commands[0] | python setup.py --version
0.2.0
__________________________________________________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________________________________________________
  version: commands succeeded
  congratulations :)

I need to capture just the version (0.2.0) from tox -e version output, what the most elegant/pythonic way of doing it ? Also is there anyway I can have tox just output the output to the command and not the rest ?

Scooby
  • 3,371
  • 8
  • 44
  • 84

2 Answers2

2

Save the version into a file. In tox.ini:

[testenv]
whitelist_externals = /bin/sh
commands =
    version: /bin/sh -c "python setup.py --version >version"

In shell:

tox -e version
cat version
rm version
phd
  • 82,685
  • 13
  • 120
  • 165
0

Including -qq in the tox command should reduce the output to just 0.2.0.

jwodder
  • 54,758
  • 12
  • 108
  • 124
  • That still prints : ➜ oktapod git:(master) ✗ tox -qq -e version ```0.2.0 version: commands succeeded congratulations :)``` – Scooby Jul 25 '18 at 15:53