Skip to content

Commit 23dd96f

Browse files
authored
Fix: accept hyphens in generative section names (#1647)
1 parent d150256 commit 23dd96f

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Stephen Finucane
9494
Sviatoslav Sydorenko
9595
Thomas Grainger
9696
Tim Laurence
97+
Tyagraj Desigar
9798
Ville Skyttä
9899
Xander Johnson
99100
anatoly techtonik

docs/changelog/1636.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow hyphens and empty factors in generative section name. - by :user:`tyagdit`

src/tox/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ def expand_section_names(config):
14201420
The parser will see it as two different sections: [testenv:py36-cov], [testenv:py37-cov]
14211421
14221422
"""
1423-
factor_re = re.compile(r"\{\s*([\w\s,]+)\s*\}")
1423+
factor_re = re.compile(r"\{\s*([\w\s,-]+)\s*\}")
14241424
split_re = re.compile(r"\s*,\s*")
14251425
to_remove = set()
14261426
for section in list(config.sections):

tests/unit/config/test_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,11 @@ def test_getbool(self, newconfig):
865865
def test_expand_section_name(self, newconfig):
866866
config = newconfig(
867867
"""
868-
[testenv:custom-{one,two,three}-{four,five}-six]
868+
[testenv:custom{,-one,-two,-three}-{four,five}-six]
869869
""",
870870
)
871871
assert "testenv:custom-one-five-six" in config._cfg.sections
872+
assert "testenv:custom-four-six" in config._cfg.sections
872873
assert "testenv:custom-{one,two,three}-{four,five}-six" not in config._cfg.sections
873874

874875

0 commit comments

Comments
 (0)