-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add Poetry PEP 621 unit and functional tests
- Loading branch information
1 parent
b9ace6d
commit befb7d1
Showing
7 changed files
with
271 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[virtualenvs] | ||
in-project = true |
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,34 @@ | ||
[project] | ||
name = "foo" | ||
version = "0.0.1" | ||
description = "" | ||
authors = [] | ||
requires-python = ">=3.9" | ||
dependencies = [ | ||
"arrow==1.3.0", | ||
"pkginfo==1.11.2", | ||
"requests", | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
requests = { git = "https://github.com/psf/requests", tag = "v2.32.3" } | ||
|
||
[project.optional-dependencies] | ||
foo = [ | ||
"click==8.1.7", | ||
"isort==5.13.2", | ||
] | ||
bar = ["urllib3==2.2.3"] | ||
|
||
[tool.poetry.dev-dependencies] | ||
black = "24.10.0" | ||
|
||
[tool.poetry.group.lint.dependencies] | ||
mypy = "1.13.0" | ||
|
||
[tool.poetry.group.test.dependencies] | ||
pytest = "8.3.3" | ||
pytest-cov = "5.0.0" | ||
|
||
[tool.deptry.per_rule_ignores] | ||
DEP002 = ["pkginfo"] |
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,10 @@ | ||
from os import chdir, walk | ||
from pathlib import Path | ||
|
||
import black | ||
import click | ||
import mypy | ||
import pytest | ||
import pytest_cov | ||
import white as w | ||
from urllib3 import contrib |
37 changes: 37 additions & 0 deletions
37
tests/fixtures/project_with_poetry_pep_621/src/notebook.ipynb
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,37 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "9f4924ec-2200-4801-9d49-d4833651cbc4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import click\n", | ||
"from urllib3 import contrib\n", | ||
"import arrow" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,108 @@ | ||
from __future__ import annotations | ||
|
||
import uuid | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from tests.functional.utils import Project | ||
from tests.utils import get_issues_report | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import PoetryVenvFactory | ||
|
||
|
||
@pytest.mark.xdist_group(name=Project.POETRY_PEP_621) | ||
def test_cli_with_poetry_pep_621(poetry_venv_factory: PoetryVenvFactory) -> None: | ||
with poetry_venv_factory(Project.POETRY_PEP_621) as virtual_env: | ||
issue_report = f"{uuid.uuid4()}.json" | ||
result = virtual_env.run(f"deptry . -o {issue_report}") | ||
|
||
assert result.returncode == 1 | ||
assert get_issues_report(Path(issue_report)) == [ | ||
{ | ||
"error": { | ||
"code": "DEP002", | ||
"message": "'requests' defined as a dependency but not used in the codebase", | ||
}, | ||
"module": "requests", | ||
"location": { | ||
"file": str(Path("pyproject.toml")), | ||
"line": None, | ||
"column": None, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP002", | ||
"message": "'isort' defined as a dependency but not used in the codebase", | ||
}, | ||
"module": "isort", | ||
"location": { | ||
"file": str(Path("pyproject.toml")), | ||
"line": None, | ||
"column": None, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP004", | ||
"message": "'black' imported but declared as a dev dependency", | ||
}, | ||
"module": "black", | ||
"location": { | ||
"file": str(Path("src/main.py")), | ||
"line": 4, | ||
"column": 8, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP004", | ||
"message": "'mypy' imported but declared as a dev dependency", | ||
}, | ||
"module": "mypy", | ||
"location": { | ||
"file": str(Path("src/main.py")), | ||
"line": 6, | ||
"column": 8, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP004", | ||
"message": "'pytest' imported but declared as a dev dependency", | ||
}, | ||
"module": "pytest", | ||
"location": { | ||
"file": str(Path("src/main.py")), | ||
"line": 7, | ||
"column": 8, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP004", | ||
"message": "'pytest_cov' imported but declared as a dev dependency", | ||
}, | ||
"module": "pytest_cov", | ||
"location": { | ||
"file": str(Path("src/main.py")), | ||
"line": 8, | ||
"column": 8, | ||
}, | ||
}, | ||
{ | ||
"error": { | ||
"code": "DEP001", | ||
"message": "'white' imported but missing from the dependency definitions", | ||
}, | ||
"module": "white", | ||
"location": { | ||
"file": str(Path("src/main.py")), | ||
"line": 9, | ||
"column": 8, | ||
}, | ||
}, | ||
] |
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