Skip to content
Discussion options

You must be logged in to vote

Hi @luziferius, great question!

The missing piece is extend = true on the conditional replacement. Without it, tox appends the then value as a single element into the commands list, which creates an extra level of nesting that fails validation. With extend = true, the contents are unpacked into the parent list instead.

For your specific use case (conditionally adding --numprocesses=auto), the simplest approach is to keep a single command and conditionally inject the extra argument:

commands = [["pytest", { replace = "if", condition = "factor.linux", then = ["--numprocesses=auto"], extend = true }]]

On linux this runs pytest --numprocesses=auto, on other platforms just pytest.

If you need …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@luziferius
Comment options

Answer selected by gaborbernat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants