Commit d40ba887 by Cauê Baasch de Souza Committed by Sébastien Eustace

Allow empty license in init (#277)

* Allow empty license in init's license validation

* Add test for empty license in interactive init
parent ea65ea92
......@@ -296,6 +296,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
def _validate_license(self, license):
from poetry.spdx import license_by_id
if license:
license_by_id(license)
return license
......
......@@ -113,3 +113,44 @@ pytest = "^3.6"
"""
assert expected in output
def test_empty_license(app, mocker, poetry):
command = app.find("init")
command._pool = poetry.pool
mocker.patch("poetry.utils._compat.Path.open")
p = mocker.patch("poetry.utils._compat.Path.cwd")
p.return_value = Path(__file__)
tester = CommandTester(command)
tester.set_inputs(
[
"my-package", # Package name
"1.2.3", # Version
"", # Description
"n", # Author
"", # License
"", # Python
"n", # Interactive packages
"n", # Interactive dev packages
"\n", # Generate
]
)
tester.execute([("command", command.name)])
output = tester.get_display(True)
expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "*"
[tool.poetry.dev-dependencies]
"""
assert expected in output
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