diff --git a/src/poetry/core/packages/dependency_group.py b/src/poetry/core/packages/dependency_group.py index 9401d1485..2da7f3065 100644 --- a/src/poetry/core/packages/dependency_group.py +++ b/src/poetry/core/packages/dependency_group.py @@ -26,7 +26,20 @@ def name(self) -> str: @property def dependencies(self) -> list[Dependency]: - return self._dependencies or self._poetry_dependencies + if not self._dependencies: + return self._poetry_dependencies + if self._poetry_dependencies: + if all(dep.is_optional() for dep in self._dependencies): + return [ + *self._dependencies, + *(d for d in self._poetry_dependencies if not d.is_optional()), + ] + if all(not dep.is_optional() for dep in self._dependencies): + return [ + *self._dependencies, + *(d for d in self._poetry_dependencies if d.is_optional()), + ] + return self._dependencies @property def dependencies_for_locking(self) -> list[Dependency]: @@ -40,7 +53,7 @@ def dependencies_for_locking(self) -> list[Dependency]: poetry_dependencies_by_name[dep.name].append(dep) dependencies = [] - for dep in self._dependencies: + for dep in self.dependencies: if dep.name in poetry_dependencies_by_name: enriched = False dep_marker = dep.marker diff --git a/tests/fixtures/sample_project_dynamic/README.rst b/tests/fixtures/sample_project_dynamic/README.rst new file mode 100644 index 000000000..f7fe15470 --- /dev/null +++ b/tests/fixtures/sample_project_dynamic/README.rst @@ -0,0 +1,2 @@ +My Package +========== diff --git a/tests/fixtures/sample_project_dynamic/pyproject.toml b/tests/fixtures/sample_project_dynamic/pyproject.toml new file mode 100644 index 000000000..7d5b48d52 --- /dev/null +++ b/tests/fixtures/sample_project_dynamic/pyproject.toml @@ -0,0 +1,83 @@ +[project] +name = "my-package" +version = "1.2.3" +description = "Some description." +readme = "README.rst" +requires-python = ">=3.6" +license = { text = "MIT" } +keywords = ["packaging", "dependency", "poetry"] +authors = [ + { name = "Sébastien Eustace", email = "sebastien@eustace.io" } +] +maintainers = [ + { name = "Sébastien Eustace", email = "sebastien@eustace.io" } +] +dynamic = [ "version", "readme", "dependencies", "classifiers" ] + +[project.optional-dependencies] +db = [ + "orator ~=0.9" +] +network = [ + "requests[security] ~=2.18" +] + +[project.urls] +homepage = "https://python-poetry.org" +repository = "/~https://github.com/python-poetry/poetry" +documentation = "https://python-poetry.org/docs" + +[project.scripts] +my-script = "my_package:main" + +[tool.poetry] +version = "1.2.3" +readme = "README.rst" +classifiers = [ + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Libraries :: Python Modules" +] + +# Requirements +[tool.poetry.dependencies] +python = ">=3.6" +cleo = "^0.6" +pendulum = { git = "/~https://github.com/sdispater/pendulum.git", branch = "2.0" } +tomlkit = { git = "/~https://github.com/sdispater/tomlkit.git", rev = "3bff550", develop = true } +pathlib2 = { version = "^2.2", python = "~2.7" } + +# File dependency +demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } + +# Dir dependency with setup.py +my-package = { path = "../project_with_setup/" } + +# Dir dependency with pyproject.toml +simple-project = { path = "../simple_project/" } + +# Dependency with markers +functools32 = { version = "^3.2.3", markers = "python_version ~= '2.7' and sys_platform == 'win32' or python_version in '3.4 3.5'" } + +# Dependency with python constraint +dataclasses = { version = "^0.7", python = ">=3.6.1,<3.7" } + + +# 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.group.dev.dependencies] +pytest = "~3.4" + + +[tool.poetry.scripts] +my-script = "my_package:main" + + +[tool.poetry.plugins."blogtool.parsers"] +".rst" = "some_module::SomeClass" diff --git a/tests/masonry/builders/fixtures/complete_dynamic/AUTHORS b/tests/masonry/builders/fixtures/complete_dynamic/AUTHORS new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/COPYING b/tests/masonry/builders/fixtures/complete_dynamic/COPYING new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/LICENCE b/tests/masonry/builders/fixtures/complete_dynamic/LICENCE new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/LICENSE b/tests/masonry/builders/fixtures/complete_dynamic/LICENSE new file mode 100644 index 000000000..44cf2b30e --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2018 Sébastien Eustace + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/masonry/builders/fixtures/complete_dynamic/README.rst b/tests/masonry/builders/fixtures/complete_dynamic/README.rst new file mode 100644 index 000000000..f7fe15470 --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/README.rst @@ -0,0 +1,2 @@ +My Package +========== diff --git a/tests/masonry/builders/fixtures/complete_dynamic/bin/script.sh b/tests/masonry/builders/fixtures/complete_dynamic/bin/script.sh new file mode 100644 index 000000000..2a9686ac6 --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/bin/script.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo "Hello World!" \ No newline at end of file diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/__init__.py b/tests/masonry/builders/fixtures/complete_dynamic/my_package/__init__.py new file mode 100644 index 000000000..10aa336ce --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/my_package/__init__.py @@ -0,0 +1 @@ +__version__ = "1.2.3" diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/data1/test.json b/tests/masonry/builders/fixtures/complete_dynamic/my_package/data1/test.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/my_package/data1/test.json @@ -0,0 +1 @@ +{} diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg1/__init__.py b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg1/extra_file.xml b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg1/extra_file.xml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/__init__.py b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/data2/data.json b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/data2/data.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg2/data2/data.json @@ -0,0 +1 @@ +{} diff --git a/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg3/foo.py b/tests/masonry/builders/fixtures/complete_dynamic/my_package/sub_pkg3/foo.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/masonry/builders/fixtures/complete_dynamic/pyproject.toml b/tests/masonry/builders/fixtures/complete_dynamic/pyproject.toml new file mode 100644 index 000000000..d37dcc4eb --- /dev/null +++ b/tests/masonry/builders/fixtures/complete_dynamic/pyproject.toml @@ -0,0 +1,62 @@ +[project] +name = "my-package" +version = "1.2.3" +description = "Some description." +requires-python = ">=3.6,<4.0" +license = { "text" = "MIT" } +authors = [ + { "name" = "Sébastien Eustace", "email" = "sebastien@eustace.io" } +] +maintainers = [ + { name = "People Everywhere", email = "people@everywhere.com" } +] +keywords = ["packaging", "dependency", "poetry"] +dynamic = [ "version", "classifiers", "readme", "dependencies" ] + +[project.optional-dependencies] +time = [ "pendulum>=1.4,<2.0 ; python_version ~= '2.7' and sys_platform == 'win32' or python_version in '3.4 3.5'" ] + +[project.urls] +homepage = "https://python-poetry.org/" +repository = "/~https://github.com/python-poetry/poetry" +documentation = "https://python-poetry.org/docs" +"Issue Tracker" = "/~https://github.com/python-poetry/poetry/issues" + +[project.scripts] +my-script = "my_package:main" +my-2nd-script = "my_package:main2" +extra-script = "my_package.extra:main" + +[project.entry-points."poetry.application.plugin"] +my-command = "my_package.plugins:MyApplicationPlugin" + + +[tool.poetry] +version = "1.2.3" +readme = "README.rst" + +classifiers = [ + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Libraries :: Python Modules" +] + +exclude = [ + "does-not-exist", + "**/*.xml" +] + +# Requirements +[tool.poetry.dependencies] +cleo = "^0.6" +cachy = { version = "^0.2.0", extras = ["msgpack"] } + +[tool.poetry.dependencies.pendulum] +version = "^1.4" +markers = 'python_version ~= "2.7" and sys_platform == "win32" or python_version in "3.4 3.5"' +optional = true + +[tool.poetry.group.dev.dependencies] +pytest = "~3.4" + +[tool.poetry.scripts] +file-script = { reference = "bin/script.sh", type = "file" } diff --git a/tests/masonry/builders/test_complete.py b/tests/masonry/builders/test_complete.py index 4fe4e1523..6d10ff9ab 100644 --- a/tests/masonry/builders/test_complete.py +++ b/tests/masonry/builders/test_complete.py @@ -102,7 +102,7 @@ def test_wheel_c_extension(project: str, exptected_c_dir: str) -> None: assert len(set(record_files)) == len(record_files) -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) @pytest.mark.parametrize("no_vcs", [False, True]) def test_complete(project: str, no_vcs: bool) -> None: module_path = fixtures_dir / project diff --git a/tests/masonry/builders/test_sdist.py b/tests/masonry/builders/test_sdist.py index 6e205db8a..bc571776f 100644 --- a/tests/masonry/builders/test_sdist.py +++ b/tests/masonry/builders/test_sdist.py @@ -120,7 +120,9 @@ def test_convert_dependencies() -> None: assert result == (main, extras) -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_make_setup(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) @@ -156,7 +158,9 @@ def test_make_setup(project_name: str) -> None: } -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_make_pkg_info(project_name: str, mocker: MockerFixture) -> None: get_metadata_content = mocker.patch( "poetry.core.masonry.builders.builder.Builder.get_metadata_content" @@ -180,7 +184,9 @@ def test_make_pkg_info_any_python() -> None: assert "Requires-Python" not in parsed -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_find_files_to_add(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) @@ -239,7 +245,9 @@ def test_make_pkg_info_multi_constraints_dependency() -> None: ] -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_find_packages(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) @@ -277,7 +285,9 @@ def test_find_packages(project_name: str) -> None: assert pkg_data == {"": ["*"]} -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_package(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) @@ -309,7 +319,9 @@ def test_package_target_dir(tmp_path: Path, target_dir: str | None) -> None: assert "my_package-1.2.3/LICENSE" in tar.getnames() -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_sdist_reproducibility(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) @@ -328,7 +340,9 @@ def test_sdist_reproducibility(project_name: str) -> None: assert len(hashes) == 1 -@pytest.mark.parametrize("project_name", ["complete", "complete_new"]) +@pytest.mark.parametrize( + "project_name", ["complete", "complete_new", "complete_dynamic"] +) def test_setup_py_context(project_name: str) -> None: poetry = Factory().create_poetry(project(project_name)) diff --git a/tests/masonry/builders/test_wheel.py b/tests/masonry/builders/test_wheel.py index a66d5fef8..0feb0cffe 100644 --- a/tests/masonry/builders/test_wheel.py +++ b/tests/masonry/builders/test_wheel.py @@ -73,7 +73,7 @@ def test_wheel_module() -> None: assert "module1.py" in z.namelist() -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_wheel_package(project: str) -> None: module_path = fixtures_dir / project WheelBuilder.make(Factory().create_poetry(module_path)) @@ -231,7 +231,7 @@ def test_wheel_build_script_creates_package() -> None: shutil.rmtree(module_path / "my_package") -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_dist_info_file_permissions(project: str) -> None: module_path = fixtures_dir / project WheelBuilder.make(Factory().create_poetry(module_path)) diff --git a/tests/masonry/test_api.py b/tests/masonry/test_api.py index f86418865..8b6377cee 100644 --- a/tests/masonry/test_api.py +++ b/tests/masonry/test_api.py @@ -35,21 +35,21 @@ def cwd(directory: str | Path) -> Iterator[None]: fixtures = Path(__file__).parent / "builders" / "fixtures" -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_get_requires_for_build_wheel(project: str) -> None: expected: list[str] = [] with cwd(fixtures / project): assert api.get_requires_for_build_wheel() == expected -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_get_requires_for_build_sdist(project: str) -> None: expected: list[str] = [] with cwd(fixtures / project): assert api.get_requires_for_build_sdist() == expected -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_build_wheel(project: str) -> None: with temporary_directory() as tmp_dir, cwd(fixtures / project): filename = api.build_wheel(str(tmp_dir)) @@ -94,7 +94,7 @@ def test_build_wheel_extended() -> None: validate_wheel_contents(name="extended", version="0.1", path=whl) -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_build_sdist(project: str) -> None: with temporary_directory() as tmp_dir, cwd(fixtures / project): filename = api.build_sdist(str(tmp_dir)) @@ -131,7 +131,7 @@ def test_build_sdist_with_bad_path_dep_succeeds(caplog: LogCaptureFixture) -> No assert "does not exist" in record.message -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_prepare_metadata_for_build_wheel(project: str) -> None: entry_points = """\ [console_scripts] @@ -224,7 +224,7 @@ def test_prepare_metadata_for_build_wheel_with_bad_path_dep_succeeds( assert "does not exist" in record.message -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_build_editable_wheel(project: str) -> None: pkg_dir = fixtures / project with temporary_directory() as tmp_dir, cwd(pkg_dir): @@ -244,7 +244,7 @@ def test_build_editable_wheel(project: str) -> None: assert z.read("my_package.pth").decode().strip() == pkg_dir.as_posix() -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_build_wheel_with_metadata_directory(project: str) -> None: pkg_dir = fixtures / project @@ -272,7 +272,7 @@ def test_build_wheel_with_metadata_directory(project: str) -> None: assert f"{metadata_directory}/CUSTOM" in namelist -@pytest.mark.parametrize("project", ["complete", "complete_new"]) +@pytest.mark.parametrize("project", ["complete", "complete_new", "complete_dynamic"]) def test_build_editable_wheel_with_metadata_directory(project: str) -> None: pkg_dir = fixtures / project diff --git a/tests/packages/test_dependency_group.py b/tests/packages/test_dependency_group.py index b6f189f16..a3cb1ac72 100644 --- a/tests/packages/test_dependency_group.py +++ b/tests/packages/test_dependency_group.py @@ -16,6 +16,7 @@ def create_dependency( name: str, constraint: str = "*", *, + optional: bool = False, extras: tuple[str, ...] = (), in_extras: tuple[str, ...] = (), allows_prereleases: bool | None = None, @@ -26,10 +27,12 @@ def create_dependency( dep = Dependency( name=name, constraint=constraint, + optional=optional, extras=extras, allows_prereleases=allows_prereleases, ) if in_extras: + dep._optional = True dep._in_extras = [canonicalize_name(extra) for extra in in_extras] if develop: dep._develop = develop @@ -47,23 +50,51 @@ def create_dependency( "expected_dependencies", ), [ - ({"foo"}, set(), {"foo"}), - (set(), {"bar"}, {"bar"}), - ({"foo"}, {"bar"}, {"foo"}), + ({Dependency("foo", "*", optional=True)}, set(), {"foo"}), + (set(), {Dependency("bar", "*")}, {"bar"}), + (set(), {Dependency("bar", "*", optional=True)}, {"bar"}), + ({Dependency("foo", "*")}, {Dependency("bar", "*")}, {"foo"}), + ( + {Dependency("foo", "*", optional=True)}, + {Dependency("bar", "*")}, + {"foo", "bar"}, + ), + ( + {Dependency("foo", "*")}, + {Dependency("bar", "*", optional=True)}, + {"foo", "bar"}, + ), + ( + { + Dependency("foo", "*", optional=True), + Dependency("baz", "*", optional=True), + }, + {Dependency("bar", "*")}, + {"foo", "bar", "baz"}, + ), + ( + { + Dependency("foo", "*", optional=True), + Dependency("baz", "*", optional=False), + }, + {Dependency("bar", "*")}, + {"foo", "baz"}, + ), + ( + {Dependency("foo", "*", optional=True)}, + {Dependency("bar", "*"), Dependency("baz", "*", optional=True)}, + {"foo", "bar"}, + ), ], ) def test_dependencies( - dependencies: set[str], - poetry_dependencies: set[str], + dependencies: set[Dependency], + poetry_dependencies: set[Dependency], expected_dependencies: set[str], ) -> None: group = DependencyGroup(name="group") - group._dependencies = [ - Dependency(name=name, constraint="*") for name in dependencies - ] - group._poetry_dependencies = [ - Dependency(name=name, constraint="*") for name in poetry_dependencies - ] + group._dependencies = list(dependencies) + group._poetry_dependencies = list(poetry_dependencies) assert {d.name for d in group.dependencies} == set(expected_dependencies) @@ -125,6 +156,21 @@ def test_remove_dependency_removes_from_both_lists() -> None: [ ([Dependency.create_from_pep_508("foo")], [], [create_dependency("foo")]), ([], [Dependency.create_from_pep_508("bar")], [create_dependency("bar")]), + ( + [create_dependency("foo")], + [create_dependency("bar")], + [create_dependency("foo")], + ), + ( + [create_dependency("foo", in_extras=("extra1",))], + [create_dependency("bar")], + [create_dependency("foo", in_extras=("extra1",)), create_dependency("bar")], + ), + ( + [create_dependency("foo")], + [create_dependency("bar", in_extras=("extra1",))], + [create_dependency("foo"), create_dependency("bar", in_extras=("extra1",))], + ), # refine constraint ( [Dependency.create_from_pep_508("foo>=1")], @@ -258,11 +304,11 @@ def test_remove_dependency_removes_from_both_lists() -> None: ( [Dependency.create_from_pep_508("foo[extra1,extra2]")], [create_dependency("foo", source_name="src")], - [create_dependency("foo", source_name="src", extras=["extra1", "extra2"])], + [create_dependency("foo", source_name="src", extras=("extra1", "extra2"))], ), ( [Dependency.create_from_pep_508("foo;extra=='extra1'")], - [create_dependency("foo", source_name="src")], + [create_dependency("foo", source_name="src", optional=True)], [create_dependency("foo", source_name="src", marker="extra == 'extra1'")], ), # extras - special diff --git a/tests/test_factory.py b/tests/test_factory.py index 0f7554508..4ccf94b94 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -160,9 +160,12 @@ def complete_legacy_duplicate_warnings() -> list[str]: ] -@pytest.mark.parametrize("new_format", [False, True]) -def test_create_poetry(new_format: str) -> None: - project = "sample_project_new" if new_format else "sample_project" +@pytest.mark.parametrize( + "project", ["sample_project", "sample_project_new", "sample_project_dynamic"] +) +def test_create_poetry(project: str) -> None: + new_format = project == "sample_project_new" + dynamic = project == "sample_project_dynamic" poetry = Factory().create_poetry(fixtures_dir / project) assert poetry.is_package_mode @@ -219,7 +222,9 @@ def test_create_poetry(new_format: str) -> None: assert tomlkit_for_locking.develop requests = dependencies["requests"] - assert requests.pretty_constraint == (">=2.18,<3.0" if new_format else "^2.18") + assert requests.pretty_constraint == ( + ">=2.18,<3.0" if new_format or dynamic else "^2.18" + ) assert not requests.is_vcs() assert requests.allows_prereleases() is None assert requests.is_optional()