[Pytest-commit] Issue #344: Consider normalizing path separators in setenv for PATH variables (hpk42/tox)

Łukasz Rogalski issues-reply at bitbucket.org
Tue Jul 12 13:15:23 EDT 2016


New issue 344: Consider normalizing path separators in setenv for PATH variables
https://bitbucket.org/hpk42/tox/issues/344/consider-normalizing-path-separators-in

Łukasz Rogalski:

Consider following extract from tox.ini:

```
#!ini

[testenv]
setenv =
         PYTHONPATH={toxinidir}/a/;{toxinidir}/b/

```

Path separator used for PYTHONPATH (and PATH variables) is platform specific - so invocation above would work on Windows but would not on POSIX system. While usually it's solved via testing matrix, I'm not sure if that's a correct approach here. User intention is to add multiple paths to environment variable, and copy-pasting same path list and changing only their separator is a clear violation of DRY.

I was thinking about few strategies:
- always normalizing separators in PATH and PYTHONPATH variables (from colon or semicolon to `os.pathsep`). I'm not sure if it's smart to maintain any kind of whitelist in docs. Also, explicit is better than implicit, and here conversion would be performed implicitly.
- export `{os.pathsep}` as possible substitute - explicit, easy, but results in kind of ugly looking tox.ini
- add optional field in tox.ini `env_path_vars = PATH,PYTHONPATH` - normalization would be performed only for explicitly selected environment variables. It looks clean, but adds additional config parameter.

I'd be happy to implement any of these (if proposal will be accepted) - the question is, which proposal do you like the most?

Regards,
Lukasz




More information about the pytest-commit mailing list