Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-package-mode: make tests forward compatible with poetry-core #8769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/console/commands/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_check_invalid(

tester.execute("--lock")

jsonschema_error = "'description' is a required property"
fastjsonschema_error = "data must contain ['description'] properties"
custom_error = "The fields ['description'] are required in package mode."
expected_template = """\
Error: {schema_error}
Error: Project name (invalid) is same as one of its dependencies
Expand All @@ -98,7 +98,7 @@ def test_check_invalid(
"""
expected = {
expected_template.format(schema_error=schema_error)
for schema_error in (jsonschema_error, fastjsonschema_error)
for schema_error in (fastjsonschema_error, custom_error)
}

assert tester.io.fetch_error() in expected
Expand Down
26 changes: 20 additions & 6 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,20 @@ def test_create_poetry_fails_on_invalid_configuration(
with pytest.raises(RuntimeError) as e:
Factory().create_poetry(fixture_dir("invalid_pyproject") / "pyproject.toml")

expected = """\
fastjsonschema_error = "data must contain ['description'] properties"
custom_error = "The fields ['description'] are required in package mode."

expected_template = """\
The Poetry configuration is invalid:
- data must contain ['description'] properties
- {schema_error}
- Project name (invalid) is same as one of its dependencies
"""
expected = {
expected_template.format(schema_error=schema_error)
for schema_error in (fastjsonschema_error, custom_error)
}

assert str(e.value) == expected
assert str(e.value) in expected


def test_create_poetry_fails_on_nameless_project(
Expand All @@ -539,12 +546,19 @@ def test_create_poetry_fails_on_nameless_project(
with pytest.raises(RuntimeError) as e:
Factory().create_poetry(fixture_dir("nameless_pyproject") / "pyproject.toml")

expected = """\
fastjsonschema_error = "data must contain ['name'] properties"
custom_error = "The fields ['name'] are required in package mode."

expected_template = """\
The Poetry configuration is invalid:
- data must contain ['name'] properties
- {schema_error}
"""
expected = {
expected_template.format(schema_error=schema_error)
for schema_error in (fastjsonschema_error, custom_error)
}

assert str(e.value) == expected
assert str(e.value) in expected


def test_create_poetry_with_local_config(fixture_dir: FixtureDirGetter) -> None:
Expand Down