-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration test using repository poetry-core as backend
- Loading branch information
1 parent
8410e35
commit 775d8e3
Showing
5 changed files
with
102 additions
and
0 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 @@ | ||
This fixture allows testing a project that uses the repository version of `poetry-core` | ||
as a PEP 517 backend. |
Empty file.
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 @@ | ||
[tool.poetry] | ||
name = "foo" | ||
version = "1.2.3" | ||
description = "Some description." | ||
authors = ["Foo <foo@bar.com>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
homepage = "https://example.com" | ||
repository = "https://github.com/example/example" | ||
documentation = "https://example.com" | ||
|
||
keywords = ["example", "packaging"] | ||
|
||
classifiers = [ | ||
"Topic :: Software Development :: Build Tools", | ||
"Topic :: Software Development :: Libraries :: Python Modules" | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.7" | ||
attrs = "^22.1.0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "7.1.3" | ||
|
||
# Non-regression test for https://github.com/python-poetry/poetry-core/pull/492. | ||
# The underlying issue occurred because `tomlkit` can either return a TOML table as `Table` instance or an | ||
# `OutOfOrderProxy` one, if a table is discontinuous and multiple sections of a table are separated by a non-related | ||
# table, but we were too strict in our type check assertions. | ||
# So adding `tool.black` here ensure that we have discontinuous tables, so that we don't re-introduce the issue caused | ||
# by the type check assertion that ended up being reverted. | ||
[tool.black] | ||
preview = true | ||
|
||
[tool.poetry.scripts] | ||
my-script = "my_package:main" |
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,54 @@ | ||
from __future__ import annotations | ||
|
||
import shutil | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from tests.testutils import subprocess_run | ||
|
||
|
||
pytestmark = pytest.mark.integration | ||
|
||
|
||
BUILD_SYSTEM_TEMPLATE = """ | ||
[build-system] | ||
requires = ["poetry-core @ file://{project_path}"] | ||
build-backend = "poetry.core.masonry.api" | ||
""" | ||
|
||
|
||
def test_pip_install( | ||
temporary_directory: Path, project_source_root: Path, python: str | ||
) -> None: | ||
""" | ||
Ensure that a project using the repository version of poetry-core as a PEP 517 backend can be built. | ||
""" | ||
temp_pep_517_backend_path = temporary_directory / "pep_517_backend" | ||
|
||
# Copy `pep_517_backend` to a temporary directory as we need to dynamically add the | ||
# build system during the test. This ensures that we don't update the source, since | ||
# the value of `requires` is dynamic. | ||
shutil.copytree( | ||
Path(__file__).parent.parent / "fixtures/pep_517_backend", | ||
temp_pep_517_backend_path, | ||
) | ||
|
||
# Append dynamic `build-system` section to `pyproject.toml` in the temporary | ||
# project directory. | ||
with open(temp_pep_517_backend_path / "pyproject.toml", "a") as f: | ||
f.write( | ||
BUILD_SYSTEM_TEMPLATE.format(project_path=project_source_root.as_posix()) | ||
) | ||
|
||
subprocess_run( | ||
python, | ||
"-m", | ||
"pip", | ||
"install", | ||
temp_pep_517_backend_path.as_posix(), | ||
) | ||
|
||
pip_show = subprocess_run(python, "-m", "pip", "show", "foo") | ||
assert "Name: foo" in pip_show.stdout |