Skip to content

Fix: accept hyphens in generative section names #1647

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

Merged
merged 3 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Stephen Finucane
Sviatoslav Sydorenko
Thomas Grainger
Tim Laurence
Tyagraj Desigar
Ville Skyttä
Xander Johnson
anatoly techtonik
1 change: 1 addition & 0 deletions docs/changelog/1636.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow hyphens and empty factors in generative section name. - by :user:`tyagdit`
2 changes: 1 addition & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ def expand_section_names(config):
The parser will see it as two different sections: [testenv:py36-cov], [testenv:py37-cov]

"""
factor_re = re.compile(r"\{\s*([\w\s,]+)\s*\}")
factor_re = re.compile(r"\{\s*([\w\s,-]+)\s*\}")
split_re = re.compile(r"\s*,\s*")
to_remove = set()
for section in list(config.sections):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,11 @@ def test_getbool(self, newconfig):
def test_expand_section_name(self, newconfig):
config = newconfig(
"""
[testenv:custom-{one,two,three}-{four,five}-six]
[testenv:custom{,-one,-two,-three}-{four,five}-six]
""",
)
assert "testenv:custom-one-five-six" in config._cfg.sections
assert "testenv:custom-four-six" in config._cfg.sections
assert "testenv:custom-{one,two,three}-{four,five}-six" not in config._cfg.sections


Expand Down