-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nox task to verify dependency declarations (#236)
- Loading branch information
1 parent
9876aa8
commit 3e1c23e
Showing
5 changed files
with
229 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Unreleased | ||
|
||
## ✨ Added | ||
|
||
* #233: Added nox task to verify dependency declarations |
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 |
---|---|---|
|
@@ -68,5 +68,6 @@ def check(session: Session) -> None: | |
python_files, | ||
) | ||
|
||
|
||
# isort: on | ||
# fmt: on |
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,147 @@ | ||
import pytest | ||
import rich.console | ||
|
||
from exasol.toolbox.nox._lint import Dependencies, report_illegal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"toml,expected", | ||
[ | ||
( | ||
""" | ||
""", | ||
{} | ||
), | ||
( | ||
""" | ||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
example-url1 = {url = "https://example.com/my-package-0.1.0.tar.gz"} | ||
[tool.poetry.dev.dependencies] | ||
nox = ">=2022.8.7" | ||
example-url2 = {url = "https://example.com/my-package-0.2.0.tar.gz"} | ||
[tool.poetry.group.test.dependencies] | ||
sphinx = ">=5.3,<8" | ||
example-git = {git = "[email protected]:requests/requests.git"} | ||
[tool.poetry.group.dev.dependencies] | ||
pytest = ">=7.2.2,<9" | ||
example-path1 = {path = "../my-package/dist/my-package-0.1.0.tar.gz"} | ||
""", | ||
{ | ||
"tool.poetry.dependencies": ["example-url1 = {'url': 'https://example.com/my-package-0.1.0.tar.gz'}"], | ||
"tool.poetry.dev.dependencies": ["example-url2 = {'url': 'https://example.com/my-package-0.2.0.tar.gz'}"], | ||
"tool.poetry.group.test.dependencies": ["example-git = {'git': '[email protected]:requests/requests.git'}"], | ||
"tool.poetry.group.dev.dependencies": ["example-path1 = {'path': '../my-package/dist/my-package-0.1.0.tar.gz'}"], | ||
} | ||
), | ||
( | ||
""" | ||
[tool.poetry.dev.dependencies] | ||
nox = ">=2022.8.7" | ||
example-url2 = {url = "https://example.com/my-package-0.2.0.tar.gz"} | ||
[tool.poetry.group.test.dependencies] | ||
sphinx = ">=5.3,<8" | ||
example-git = {git = "[email protected]:requests/requests.git"} | ||
[tool.poetry.group.dev.dependencies] | ||
pytest = ">=7.2.2,<9" | ||
example-path1 = {path = "../my-package/dist/my-package-0.1.0.tar.gz"} | ||
""", | ||
{ | ||
"tool.poetry.dev.dependencies": ["example-url2 = {'url': 'https://example.com/my-package-0.2.0.tar.gz'}"], | ||
"tool.poetry.group.test.dependencies": ["example-git = {'git': '[email protected]:requests/requests.git'}"], | ||
"tool.poetry.group.dev.dependencies": ["example-path1 = {'path': '../my-package/dist/my-package-0.1.0.tar.gz'}"], | ||
} | ||
), | ||
( | ||
""" | ||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
example-url1 = {url = "https://example.com/my-package-0.1.0.tar.gz"} | ||
[tool.poetry.group.test.dependencies] | ||
sphinx = ">=5.3,<8" | ||
example-git = {git = "[email protected]:requests/requests.git"} | ||
[tool.poetry.group.dev.dependencies] | ||
pytest = ">=7.2.2,<9" | ||
example-path1 = {path = "../my-package/dist/my-package-0.1.0.tar.gz"} | ||
""", | ||
{ | ||
"tool.poetry.dependencies": ["example-url1 = {'url': 'https://example.com/my-package-0.1.0.tar.gz'}"], | ||
"tool.poetry.group.test.dependencies": ["example-git = {'git': '[email protected]:requests/requests.git'}"], | ||
"tool.poetry.group.dev.dependencies": ["example-path1 = {'path': '../my-package/dist/my-package-0.1.0.tar.gz'}"], | ||
} | ||
), | ||
( | ||
""" | ||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
example-url1 = {url = "https://example.com/my-package-0.1.0.tar.gz"} | ||
[tool.poetry.dev.dependencies] | ||
nox = ">=2022.8.7" | ||
example-url2 = {url = "https://example.com/my-package-0.2.0.tar.gz"} | ||
""", | ||
{ | ||
"tool.poetry.dependencies": ["example-url1 = {'url': 'https://example.com/my-package-0.1.0.tar.gz'}"], | ||
"tool.poetry.dev.dependencies": ["example-url2 = {'url': 'https://example.com/my-package-0.2.0.tar.gz'}"], | ||
} | ||
) | ||
] | ||
) | ||
def test_dependency_check_parse(toml, expected): | ||
dependencies = dependencies = Dependencies.parse(toml) | ||
assert dependencies.illegal == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"toml,expected", | ||
[ | ||
( | ||
""" | ||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
example-url1 = {url = "https://example.com/my-package-0.1.0.tar.gz"} | ||
[tool.poetry.dev.dependencies] | ||
nox = ">=2022.8.7" | ||
example-url2 = {url = "https://example.com/my-package-0.2.0.tar.gz"} | ||
[tool.poetry.group.test.dependencies] | ||
sphinx = ">=5.3,<8" | ||
example-git = {git = "[email protected]:requests/requests.git"} | ||
[tool.poetry.group.dev.dependencies] | ||
pytest = ">=7.2.2,<9" | ||
example-path1 = {path = "../my-package/dist/my-package-0.1.0.tar.gz"} | ||
example-path2 = {path = "../my-package/dist/my-package-0.2.0.tar.gz"} | ||
""", | ||
"""5 illegal dependencies | ||
[tool.poetry.dependencies] | ||
example-url1 = {'url': 'https://example.com/my-package-0.1.0.tar.gz'} | ||
[tool.poetry.dev.dependencies] | ||
example-url2 = {'url': 'https://example.com/my-package-0.2.0.tar.gz'} | ||
[tool.poetry.group.test.dependencies] | ||
example-git = {'git': '[email protected]:requests/requests.git'} | ||
[tool.poetry.group.dev.dependencies] | ||
example-path1 = {'path': '../my-package/dist/my-package-0.1.0.tar.gz'} | ||
example-path2 = {'path': '../my-package/dist/my-package-0.2.0.tar.gz'} | ||
""" | ||
), | ||
] | ||
) | ||
def test_dependencies_check_report(toml, expected, capsys): | ||
console = rich.console.Console() | ||
dependencies = Dependencies.parse(toml) | ||
report_illegal(dependencies.illegal, console) | ||
assert capsys.readouterr().out == expected |