Skip to content

Commit

Permalink
non-package-mode: make tests forward compatible with poetry-core (#8769)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored Dec 17, 2023
1 parent f4f1575 commit 2c3d488
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
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

0 comments on commit 2c3d488

Please sign in to comment.