Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generative section names don't work with empty factor #1636

Closed
The-Compiler opened this issue Jul 30, 2020 · 4 comments · Fixed by #1647
Closed

Generative section names don't work with empty factor #1636

The-Compiler opened this issue Jul 30, 2020 · 4 comments · Fixed by #1647
Labels
bug:normal affects many people or has quite an impact pr-merged

Comments

@The-Compiler
Copy link
Member

If I have a tox.ini like this:

[tox]
skipsdist = true

[testenv:foo]
commands =
    {envpython} -c "print('Hello World')"

[testenv:foo-factor]
commands =
    {envpython} -c "print('Factor given')"
    {envpython} -c "print('Hello World')"

Now I'd like to simplify this to use generative section names. I'd expect to either testenv:foo{,-factor} or testenv:foo-{,factor} to work. It looks like neither does.

This:

[tox]
skipsdist = true

[testenv:foo,{-factor}]
commands =
    factor: {envpython} -c "print('Factor given')"
    {envpython} -c "print('Hello World')"

results in:

$ tox -e foo-factor
ERROR: unknown environment 'foo-factor'

(or an empty run without any commands if foo-factor is added to envlist), while this:

[tox]
skipsdist = true

[testenv:foo-{,factor}]
commands =
    factor: {envpython} -c "print('Factor given')"
    {envpython} -c "print('Hello World')"

results in:

$ tox -e foo       
ERROR: unknown environment 'foo'

(as it defines an environment called foo-, not foo).

Am I missing something, or is the currently no way to do this kind of thing?

@The-Compiler The-Compiler added the bug:normal affects many people or has quite an impact label Jul 30, 2020
@gaborbernat gaborbernat added type:question ❔ a question about how things work or if something is a bug or a feature and removed bug:normal affects many people or has quite an impact type:question ❔ a question about how things work or if something is a bug or a feature labels Jul 30, 2020
@gaborbernat
Copy link
Member

gaborbernat commented Jul 30, 2020

Generative factors are not supported within section names AFAIK. This would be a new feature request. What you could do instead is:

[tox]
skipsdist = true

[testenv:foo]
commands =
    {envpython} -c "print('Hello World')"

[testenv:foo-factor]
commands =
    {[testenv:foo]commands}
    {envpython} -c "print('Hello World')"

@gaborbernat gaborbernat added the feature:new something does not exist yet, but should label Jul 30, 2020
@The-Compiler
Copy link
Member Author

The-Compiler commented Jul 30, 2020

Generative factors are not supported within section names AFAIK.

Yes they are, the problem is just the empty factor (thus making this a bug IMHO, since empty factors work fine elsewhere). This works fine:

[tox]
skipsdist = true

[testenv:foo-factor{1,2}]
commands =
    factor1: {envpython} -c "print('Factor 1 given')"
    factor2: {envpython} -c "print('Factor 2 given')"
    {envpython} -c "print('Hello World')"
$ tox       
foo-factor1 create: ...
foo-factor1 run-test-pre: ...
foo-factor1 run-test: commands[0] | ...
Factor 1 given
foo-factor1 run-test: commands[1] | ...
Hello World

foo-factor2 create: ...
foo-factor2 run-test-pre: ...
foo-factor2 run-test: commands[0] | ...
Factor 2 given
foo-factor2 run-test: commands[1] | ...
Hello World

(output slightly edited for readability)

@gaborbernat gaborbernat added bug:normal affects many people or has quite an impact and removed feature:new something does not exist yet, but should labels Jul 31, 2020
@gaborbernat
Copy link
Member

A PR is welcomed 👍

@gaborbernat
Copy link
Member

Released via https://pypi.org/project/tox/3.20.0/

tekumara pushed a commit to seek-oss/aec that referenced this issue Sep 4, 2020
Bumps [tox](https://github.com/tox-dev/tox) from 3.19.0 to 3.20.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/tox-dev/tox/blob/master/docs/changelog.rst">tox's changelog</a>.</em></p>
<blockquote>
<h2>v3.20.0 (2020-09-01)</h2>
<p>Bugfixes
^^^^^^^^</p>
<ul>
<li>Allow hyphens and empty factors in generative section name. - by :user:<code>tyagdit</code>
<code>[#1636](tox-dev/tox#1636) &lt;https://github.com/tox-dev/tox/issues/1636&gt;</code>_</li>
<li>Support for PEP517 in-tree build backend-path key in <code>get-build-requires</code>. - by :user:<code>nizox</code>
<code>[#1654](tox-dev/tox#1654) &lt;https://github.com/tox-dev/tox/issues/1654&gt;</code>_</li>
<li>Allow escaping curly braces in setenv. - by :user:<code>mkenigs</code>
<code>[#1656](tox-dev/tox#1656) &lt;https://github.com/tox-dev/tox/issues/1656&gt;</code>_</li>
</ul>
<p>Features
^^^^^^^^</p>
<ul>
<li>Support for comments within <code>setenv</code> and environment files via the <code>files|</code> prefix. - by :user:<code>gaborbernat</code>
<code>[#1667](tox-dev/tox#1667) &lt;https://github.com/tox-dev/tox/issues/1667&gt;</code>_</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/tox-dev/tox/commit/5c94919b79105eabb0507f6d5e55b60daee11ccc"><code>5c94919</code></a> release 3.20.0</li>
<li><a href="https://github.com/tox-dev/tox/commit/8a25fa6bf3e625c0b47659e1652ab55a79d4d1e8"><code>8a25fa6</code></a> Support environment files and comments in setenv (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1668">#1668</a>)</li>
<li><a href="https://github.com/tox-dev/tox/commit/a7903508fa07068b327e15cfdbf8ea330ab78765"><code>a790350</code></a> New formatters</li>
<li><a href="https://github.com/tox-dev/tox/commit/d4e6e77ea77cf8b336f38313bef40c80b6771139"><code>d4e6e77</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1656">#1656</a> from mkenigs/escape-braces-in-setenv</li>
<li><a href="https://github.com/tox-dev/tox/commit/8e39dfbb836b6e2e6b2bd637f7b853935e82de3f"><code>8e39dfb</code></a> Spelling fixes (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1665">#1665</a>)</li>
<li><a href="https://github.com/tox-dev/tox/commit/00f6496b756f938db4ddcf040a5192a9e40b16a4"><code>00f6496</code></a> Document allowlist_externals versionadded (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1663">#1663</a>)</li>
<li><a href="https://github.com/tox-dev/tox/commit/3c38762fc6acfd6ca93ddc8607133d3a39e6d25c"><code>3c38762</code></a> Allow escaping curly braces in setenv</li>
<li><a href="https://github.com/tox-dev/tox/commit/3453018dab9a0208f64013c2dd357d1be348ffdf"><code>3453018</code></a> Make setup.py test admonition sterner as it is deprecated (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1660">#1660</a>)</li>
<li><a href="https://github.com/tox-dev/tox/commit/4b7f682db872902b542ccaf26d9619c141dfc8ab"><code>4b7f682</code></a> remove broken link to removed pytest-runner documentation (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1659">#1659</a>)</li>
<li><a href="https://github.com/tox-dev/tox/commit/f292f5236a41f7c02ba60dbc14d8e5941be7ea0e"><code>f292f52</code></a> Fix support of the PEP517 backend-path key (<a href="https://github-redirect.dependabot.com/tox-dev/tox/issues/1655">#1655</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tox-dev/tox/compare/3.19.0...3.20.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tox&package-manager=pip&previous-version=3.19.0&new-version=3.20.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact pr-merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants