Commit 5b94aa8e by finswimmer Committed by GitHub

init: allow whitespaces in package extras (#2985)

This fix allows having whitespaces in the list of extras during poetry 
add and init, e.g. `databases[postgresql, sqlite]`.

Resolves: #2980
parent d4eb422e
......@@ -373,7 +373,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
for requirement in requirements:
requirement = requirement.strip()
extras = []
extras_m = re.search(r"\[([\w\d,-_]+)\]$", requirement)
extras_m = re.search(r"\[([\w\d,-_ ]+)\]$", requirement)
if extras_m:
extras = [e.strip() for e in extras_m.group(1).split(",")]
requirement, _ = requirement.split("[")
......
......@@ -556,3 +556,12 @@ python = "~2.7 || ^3.6"
assert expected in output
assert 'pytest-requests = "^0.2.0"' in output
assert 'pytest = "^3.6.0"' in output
def test_add_package_with_extras_and_whitespace(tester):
result = tester._command._parse_requirements(["databases[postgresql, sqlite]"])
assert result[0]["name"] == "databases"
assert len(result[0]["extras"]) == 2
assert "postgresql" in result[0]["extras"]
assert "sqlite" in result[0]["extras"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment