Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tox run python command in sudo

Tags:

python

tox

When I try to run a test command using sudo python ..., tox uses the system Python instead of the tox-specified version. How can I run commands in sudo using tox?

commands =
    sudo python -m pytest  # always runs system python!
like image 247
jtpereyda Avatar asked Jun 18 '26 11:06

jtpereyda


1 Answers

python in Tox commands will only be replaced if it is a command. Technically, sudo python ... will run the system command sudo and pass it "python" as the first argument.

Tox provides a number of substitutions that allow for a lot of flexibility. In your case, you'll want something like

commands =
    sudo {envpython} -m pytest  # always uses the right python :)
like image 178
jtpereyda Avatar answered Jun 20 '26 00:06

jtpereyda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!