-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple README files
This code reuses the `"readme"` entry in a way to allow the user to declare in the old way or the new way. With the changes, the two following declarations are valid: **Single file** ```toml readme = "README.rst" ``` **Multiple files** ```toml readme = [ "README.rst", "HISTORY.rst" ] ``` If the user declares files in different formats, the strict validation will issue. NOTICE: The class `Package` suffered an important change: `readme` was renamed to the plural `readmes`. Properties for the single form were introduced to ensure retrocompatibility.
- Loading branch information
1 parent
fa93845
commit eb8883e
Showing
11 changed files
with
147 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Single Python | ||
============= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Changelog | ||
========= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[tool.poetry] | ||
name = "single-python" | ||
version = "0.1" | ||
description = "Some description." | ||
authors = [ | ||
"Wagner Macedo <[email protected]>" | ||
] | ||
license = "MIT" | ||
|
||
readme = [ | ||
"README-1.rst", | ||
"README-2.rst" | ||
] | ||
|
||
homepage = "https://python-poetry.org/" | ||
|
||
|
||
[tool.poetry.dependencies] | ||
python = "2.7.15" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Example module""" | ||
|
||
__version__ = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ def test_create_poetry(): | |
assert package.authors == ["Sébastien Eustace <[email protected]>"] | ||
assert package.license.id == "MIT" | ||
assert ( | ||
package.readme.relative_to(fixtures_dir).as_posix() | ||
package.readmes[0].relative_to(fixtures_dir).as_posix() | ||
== "sample_project/README.rst" | ||
) | ||
assert package.homepage == "https://python-poetry.org" | ||
|
@@ -182,6 +182,26 @@ def test_validate_fails(): | |
assert Factory.validate(content) == {"errors": [expected], "warnings": []} | ||
|
||
|
||
def test_strict_validation_success_on_multiple_readme_files(): | ||
with_readme_files = TOMLFile(fixtures_dir / "with_readme_files" / "pyproject.toml") | ||
content = with_readme_files.read()["tool"]["poetry"] | ||
|
||
assert Factory.validate(content, strict=True) == {"errors": [], "warnings": []} | ||
|
||
|
||
def test_strict_validation_fails_on_readme_files_with_unmatching_types(): | ||
with_readme_files = TOMLFile(fixtures_dir / "with_readme_files" / "pyproject.toml") | ||
content = with_readme_files.read()["tool"]["poetry"] | ||
content["readme"][0] = "README.md" | ||
|
||
assert Factory.validate(content, strict=True) == { | ||
"errors": [ | ||
"Declared README files must be of same type: found text/markdown, text/x-rst" | ||
], | ||
"warnings": [], | ||
} | ||
|
||
|
||
def test_create_poetry_fails_on_invalid_configuration(): | ||
with pytest.raises(RuntimeError) as e: | ||
Factory().create_poetry( | ||
|