4

I'm using tox to run protractor tests which will test an application which uses django+angularjs, there is a glue library (django-protractor) which makes this easier, except that it makes the call to protractor inside a django management command, and relies on $PATH to show it where protractor is.

So if I set the $PATH properly before running tox, it works fine, but I'd rather not require all the devs to do that manually.

Lefunque
  • 468
  • 5
  • 16

2 Answers2

7

To use environment variables tox provides the syntax {env:VARIABLE}. To set them tox provides the setenv section.

These can be used together to modify the PATH variable that can be used by commands:

[testenv]
setenv =
  PATH = {env:PATH}{:}/path/to/protractor

commands = 
  echo {env:PATH}

Another option that might work in some cases is symlink or download the binary in a writable path of the PATH, hopefully we always have one available: the virtual environments' binary folder, which is {envbindir} in tox.

undu
  • 71
  • 2
  • 3
  • I'm not sure PATH can be setenv. I've been trying it with unpromising results :( @undu, did you test it? – David Jul 09 '18 at 20:09
  • Just tried it: It works as expected for me on Linux. – undu Jul 27 '18 at 08:09
  • 1
    I've set up a repo with travis to show that it works: https://travis-ci.com/undu/tox-path-example/jobs/136762405 Note the /path/to/protractor just before the summary The tox configuration can be found here: https://github.com/undu/tox-path-example/blob/master/tox.ini – undu Jul 27 '18 at 08:46
2

I think it should work if you modify your path in the manage.py file to include django-protractor directory, because the Django management command line uses manage.py.

Forge
  • 6,538
  • 6
  • 44
  • 64
  • @Lefunque please consider accepting the answer if it was helpful for you by clicking the check-mark. – Forge Feb 19 '16 at 07:03