From 67bc2d9efdbc899f223ccfa641e65a15fe742a12 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Sat, 10 Oct 2020 21:09:49 -0400 Subject: [PATCH 1/5] Relates-to: #3155 converting duplicted code to fixture --- tests/console/commands/debug/test_resolve.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/console/commands/debug/test_resolve.py b/tests/console/commands/debug/test_resolve.py index ad7e94321d2..2760e7d9dc3 100644 --- a/tests/console/commands/debug/test_resolve.py +++ b/tests/console/commands/debug/test_resolve.py @@ -9,7 +9,8 @@ def tester(command_tester_factory): return command_tester_factory("debug resolve") -def test_debug_resolve_gives_resolution_results(tester, repo): +@pytest.fixture() +def cachy_repo(repo): cachy2 = get_package("cachy", "0.2.0") cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) @@ -17,6 +18,8 @@ def test_debug_resolve_gives_resolution_results(tester, repo): repo.add_package(cachy2) repo.add_package(get_package("msgpack-python", "0.5.3")) + +def test_debug_resolve_gives_resolution_results(tester, cachy_repo): tester.execute("cachy") expected = """\ @@ -31,14 +34,7 @@ def test_debug_resolve_gives_resolution_results(tester, repo): assert expected == tester.io.fetch_output() -def test_debug_resolve_tree_option_gives_the_dependency_tree(tester, repo): - cachy2 = get_package("cachy", "0.2.0") - cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - repo.add_package(get_package("msgpack-python", "0.5.3")) - +def test_debug_resolve_tree_option_gives_the_dependency_tree(tester, cachy_repo): tester.execute("cachy --tree") expected = """\ From 01609955b846cbb1453fca7519e1099cbf1abd06 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Mon, 12 Oct 2020 09:27:15 -0400 Subject: [PATCH 2/5] Adding additional packages to fixture and making it autouse --- tests/console/commands/debug/test_resolve.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/console/commands/debug/test_resolve.py b/tests/console/commands/debug/test_resolve.py index 2760e7d9dc3..465b22fc276 100644 --- a/tests/console/commands/debug/test_resolve.py +++ b/tests/console/commands/debug/test_resolve.py @@ -9,8 +9,8 @@ def tester(command_tester_factory): return command_tester_factory("debug resolve") -@pytest.fixture() -def cachy_repo(repo): +@pytest.fixture(autouse=True) +def __add_packages(repo): cachy2 = get_package("cachy", "0.2.0") cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) @@ -18,8 +18,11 @@ def cachy_repo(repo): repo.add_package(cachy2) repo.add_package(get_package("msgpack-python", "0.5.3")) + repo.add_package(get_package("pendulum", "2.0.3")) + repo.add_package(get_package("cleo", "0.6.5")) + -def test_debug_resolve_gives_resolution_results(tester, cachy_repo): +def test_debug_resolve_gives_resolution_results(tester): tester.execute("cachy") expected = """\ @@ -34,7 +37,7 @@ def test_debug_resolve_gives_resolution_results(tester, cachy_repo): assert expected == tester.io.fetch_output() -def test_debug_resolve_tree_option_gives_the_dependency_tree(tester, cachy_repo): +def test_debug_resolve_tree_option_gives_the_dependency_tree(tester): tester.execute("cachy --tree") expected = """\ @@ -49,10 +52,7 @@ def test_debug_resolve_tree_option_gives_the_dependency_tree(tester, cachy_repo) assert expected == tester.io.fetch_output() -def test_debug_resolve_git_dependency(tester, repo): - repo.add_package(get_package("pendulum", "2.0.3")) - repo.add_package(get_package("cleo", "0.6.5")) - +def test_debug_resolve_git_dependency(tester): tester.execute("git+https://github.com/demo/demo.git") expected = """\ From f084e59c07df1bc5422d947834c04f8ba27c0b47 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Mon, 12 Oct 2020 09:38:16 -0400 Subject: [PATCH 3/5] Updating variable name from cachy2 to cachy020 --- tests/console/commands/debug/test_resolve.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/console/commands/debug/test_resolve.py b/tests/console/commands/debug/test_resolve.py index 465b22fc276..ffc1e509aef 100644 --- a/tests/console/commands/debug/test_resolve.py +++ b/tests/console/commands/debug/test_resolve.py @@ -11,11 +11,11 @@ def tester(command_tester_factory): @pytest.fixture(autouse=True) def __add_packages(repo): - cachy2 = get_package("cachy", "0.2.0") - cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) + cachy020 = get_package("cachy", "0.2.0") + cachy020.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) + repo.add_package(cachy020) repo.add_package(get_package("msgpack-python", "0.5.3")) repo.add_package(get_package("pendulum", "2.0.3")) From 1fe2b19376ea08b5850cefc1e3fe10556bbf0f11 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Mon, 12 Oct 2020 23:59:40 -0400 Subject: [PATCH 4/5] Adding fixture to test add --- tests/console/commands/test_add.py | 230 ++++++++++------------------- 1 file changed, 75 insertions(+), 155 deletions(-) diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index 09fae525aec..f5bdc9ed53a 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -24,10 +24,18 @@ def old_tester(tester): return tester -def test_add_no_constraint(app, repo, tester): +@pytest.fixture() +def repo_with_packages(repo): repo.add_package(get_package("cachy", "0.1.0")) repo.add_package(get_package("cachy", "0.2.0")) + repo.add_package(get_package("pendulum", "1.4.4")) + repo.add_package(get_package("cleo", "0.6.5")) + repo.add_package(get_package("tomlkit", "0.5.5")) + repo.add_package(get_package("pyyaml", "3.13")) + repo.add_package(get_package("pyyaml", "4.2b2")) + +def test_add_no_constraint(app, repo_with_packages, tester): tester.execute("cachy") expected = """\ @@ -52,10 +60,7 @@ def test_add_no_constraint(app, repo, tester): assert content["dependencies"]["cachy"] == "^0.2.0" -def test_add_equal_constraint(app, repo, tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_equal_constraint(repo_with_packages, tester): tester.execute("cachy==0.1.0") expected = """\ @@ -74,10 +79,7 @@ def test_add_equal_constraint(app, repo, tester): assert 1 == tester._command.installer.executor.installations_count -def test_add_greater_constraint(app, repo, tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_greater_constraint(repo_with_packages, tester): tester.execute("cachy>=0.1.0") expected = """\ @@ -96,7 +98,7 @@ def test_add_greater_constraint(app, repo, tester): assert 1 == tester._command.installer.executor.installations_count -def test_add_constraint_with_extras(app, repo, tester): +def test_add_constraint_with_extras(repo, tester): cachy1 = get_package("cachy", "0.1.0") cachy1.extras = {"msgpack": [get_dependency("msgpack-python")]} msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) @@ -125,7 +127,7 @@ def test_add_constraint_with_extras(app, repo, tester): assert 2 == tester._command.installer.executor.installations_count -def test_add_constraint_dependencies(app, repo, tester): +def test_add_constraint_dependencies(repo, tester): cachy2 = get_package("cachy", "0.2.0") msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6") cachy2.requires = [msgpack_dep] @@ -153,12 +155,9 @@ def test_add_constraint_dependencies(app, repo, tester): assert 2 == tester._command.installer.executor.installations_count -def test_add_git_constraint(app, repo, tester, tmp_venv): +def test_add_git_constraint(app, repo_with_packages, tester, tmp_venv): tester._command.set_env(tmp_venv) - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - tester.execute("git+https://github.com/demo/demo.git") expected = """\ @@ -185,11 +184,9 @@ def test_add_git_constraint(app, repo, tester, tmp_venv): } -def test_add_git_constraint_with_poetry(app, repo, tester, tmp_venv): +def test_add_git_constraint_with_poetry(repo_with_packages, tester, tmp_venv): tester._command.set_env(tmp_venv) - repo.add_package(get_package("pendulum", "1.4.4")) - tester.execute("git+https://github.com/demo/pyproject-demo.git") expected = """\ @@ -209,13 +206,9 @@ def test_add_git_constraint_with_poetry(app, repo, tester, tmp_venv): assert 2 == tester._command.installer.executor.installations_count -def test_add_git_constraint_with_extras(app, repo, tester, tmp_venv): +def test_add_git_constraint_with_extras(app, repo_with_packages, tester, tmp_venv): tester._command.set_env(tmp_venv) - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - repo.add_package(get_package("tomlkit", "0.5.5")) - tester.execute("git+https://github.com/demo/demo.git[foo,bar]") expected = """\ @@ -245,12 +238,9 @@ def test_add_git_constraint_with_extras(app, repo, tester, tmp_venv): } -def test_add_git_ssh_constraint(app, repo, tester, tmp_venv): +def test_add_git_ssh_constraint(app, repo_with_packages, tester, tmp_venv): tester._command.set_env(tmp_venv) - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - tester.execute("git+ssh://git@github.com/demo/demo.git@develop") expected = """\ @@ -278,13 +268,10 @@ def test_add_git_ssh_constraint(app, repo, tester, tmp_venv): } -def test_add_directory_constraint(app, repo, tester, mocker): +def test_add_directory_constraint(app, repo_with_packages, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__).parent - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - path = "../git/github.com/demo/demo" tester.execute("{}".format(path)) @@ -312,12 +299,10 @@ def test_add_directory_constraint(app, repo, tester, mocker): assert content["dependencies"]["demo"] == {"path": "../git/github.com/demo/demo"} -def test_add_directory_with_poetry(app, repo, tester, mocker): +def test_add_directory_with_poetry(app, repo_with_packages, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../git/github.com/demo/pyproject-demo" tester.execute("{}".format(path)) @@ -340,12 +325,10 @@ def test_add_directory_with_poetry(app, repo, tester, mocker): assert 2 == tester._command.installer.executor.installations_count -def test_add_file_constraint_wheel(app, repo, tester, mocker, poetry): +def test_add_file_constraint_wheel(app, repo_with_packages, tester, mocker, poetry): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = poetry.file.parent - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" tester.execute("{}".format(path)) @@ -375,12 +358,10 @@ def test_add_file_constraint_wheel(app, repo, tester, mocker, poetry): } -def test_add_file_constraint_sdist(app, repo, tester, mocker): +def test_add_file_constraint_sdist(app, repo_with_packages, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../distributions/demo-0.1.0.tar.gz" tester.execute("{}".format(path)) @@ -447,12 +428,10 @@ def test_add_constraint_with_extras_option(app, repo, tester): } -def test_add_url_constraint_wheel(app, repo, tester, mocker): +def test_add_url_constraint_wheel(app, repo_with_packages, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl" ) @@ -481,11 +460,7 @@ def test_add_url_constraint_wheel(app, repo, tester, mocker): } -def test_add_url_constraint_wheel_with_extras(app, repo, tester, mocker): - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - repo.add_package(get_package("tomlkit", "0.5.5")) - +def test_add_url_constraint_wheel_with_extras(app, repo_with_packages, tester): tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl[foo,bar]" ) @@ -519,12 +494,7 @@ def test_add_url_constraint_wheel_with_extras(app, repo, tester, mocker): } -def test_add_constraint_with_python(app, repo, tester): - cachy2 = get_package("cachy", "0.2.0") - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - +def test_add_constraint_with_python(app, repo_with_packages, tester): tester.execute("cachy=0.2.0 --python >=2.7") expected = """\ @@ -548,15 +518,10 @@ def test_add_constraint_with_python(app, repo, tester): assert content["dependencies"]["cachy"] == {"version": "0.2.0", "python": ">=2.7"} -def test_add_constraint_with_platform(app, repo, tester, env): +def test_add_constraint_with_platform(app, repo_with_packages, tester, env): platform = sys.platform env._platform = platform - cachy2 = get_package("cachy", "0.2.0") - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - tester.execute("cachy=0.2.0 --platform {} -vvv".format(platform)) expected = """\ @@ -583,7 +548,7 @@ def test_add_constraint_with_platform(app, repo, tester, env): } -def test_add_constraint_with_source(app, poetry, tester): +def test_add_constraint_with_source(app, repo, poetry, tester): repo = LegacyRepository(name="my-index", url="https://my-index.fake") repo.add_package(get_package("cachy", "0.2.0")) repo._cache.store("matches").put("cachy:0.2.0", [Version.parse("0.2.0")], 5) @@ -616,14 +581,14 @@ def test_add_constraint_with_source(app, poetry, tester): } -def test_add_constraint_with_source_that_does_not_exist(app, tester): +def test_add_constraint_with_source_that_does_not_exist(tester): with pytest.raises(ValueError) as e: tester.execute("foo --source i-dont-exist") assert 'Repository "i-dont-exist" does not exist.' == str(e.value) -def test_add_constraint_not_found_with_source(app, poetry, mocker, tester): +def test_add_constraint_not_found_with_source(poetry, mocker, tester): repo = LegacyRepository(name="my-index", url="https://my-index.fake") mocker.patch.object(repo, "find_packages", return_value=[]) @@ -638,10 +603,7 @@ def test_add_constraint_not_found_with_source(app, poetry, mocker, tester): assert "Could not find a matching version of package cachy" == str(e.value) -def test_add_to_section_that_does_no_exist_yet(app, repo, tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_to_section_that_does_no_exist_yet(app, repo_with_packages, tester): tester.execute("cachy --dev") expected = """\ @@ -666,10 +628,7 @@ def test_add_to_section_that_does_no_exist_yet(app, repo, tester): assert content["dev-dependencies"]["cachy"] == "^0.2.0" -def test_add_should_not_select_prereleases(app, repo, tester): - repo.add_package(get_package("pyyaml", "3.13")) - repo.add_package(get_package("pyyaml", "4.2b2")) - +def test_add_should_not_select_prereleases(app, repo_with_packages, tester): tester.execute("pyyaml") expected = """\ @@ -748,7 +707,7 @@ def test_add_should_work_when_adding_existing_package_with_latest_constraint( assert content["dependencies"]["foo"] == "^1.1.2" -def test_add_chooses_prerelease_if_only_prereleases_are_available(app, repo, tester): +def test_add_chooses_prerelease_if_only_prereleases_are_available(repo, tester): repo.add_package(get_package("foo", "1.2.3b0")) repo.add_package(get_package("foo", "1.2.3b1")) @@ -770,7 +729,7 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available(app, repo, tes assert expected in tester.io.fetch_output() -def test_add_prefers_stable_releases(app, repo, tester): +def test_add_prefers_stable_releases(repo, tester): repo.add_package(get_package("foo", "1.2.3")) repo.add_package(get_package("foo", "1.2.4b1")) @@ -792,9 +751,8 @@ def test_add_prefers_stable_releases(app, repo, tester): assert expected in tester.io.fetch_output() -def test_add_with_lock(app, repo, tester): +def test_add_with_lock(app, repo_with_packages, tester): content_hash = app.poetry.locker._get_content_hash() - repo.add_package(get_package("cachy", "0.2.0")) tester.execute("cachy --lock") @@ -811,10 +769,9 @@ def test_add_with_lock(app, repo, tester): assert content_hash != app.poetry.locker.lock_data["metadata"]["content-hash"] -def test_add_no_constraint_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_no_constraint_old_installer( + app, repo_with_packages, installer, old_tester +): old_tester.execute("cachy") expected = """\ @@ -840,10 +797,7 @@ def test_add_no_constraint_old_installer(app, repo, installer, old_tester): assert content["dependencies"]["cachy"] == "^0.2.0" -def test_add_equal_constraint_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_equal_constraint_old_installer(repo_with_packages, installer, old_tester): old_tester.execute("cachy==0.1.0") expected = """\ @@ -863,10 +817,9 @@ def test_add_equal_constraint_old_installer(app, repo, installer, old_tester): assert len(installer.installs) == 1 -def test_add_greater_constraint_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_greater_constraint_old_installer( + repo_with_packages, installer, old_tester +): old_tester.execute("cachy>=0.1.0") expected = """\ @@ -886,7 +839,7 @@ def test_add_greater_constraint_old_installer(app, repo, installer, old_tester): assert len(installer.installs) == 1 -def test_add_constraint_with_extras_old_installer(app, repo, installer, old_tester): +def test_add_constraint_with_extras_old_installer(repo, installer, old_tester): cachy1 = get_package("cachy", "0.1.0") cachy1.extras = {"msgpack": [get_dependency("msgpack-python")]} msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) @@ -916,7 +869,7 @@ def test_add_constraint_with_extras_old_installer(app, repo, installer, old_test assert len(installer.installs) == 2 -def test_add_constraint_dependencies_old_installer(app, repo, installer, old_tester): +def test_add_constraint_dependencies_old_installer(repo, installer, old_tester): cachy2 = get_package("cachy", "0.2.0") msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6") cachy2.requires = [msgpack_dep] @@ -945,10 +898,9 @@ def test_add_constraint_dependencies_old_installer(app, repo, installer, old_tes assert len(installer.installs) == 2 -def test_add_git_constraint_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - +def test_add_git_constraint_old_installer( + app, repo_with_packages, installer, old_tester +): old_tester.execute("git+https://github.com/demo/demo.git") expected = """\ @@ -976,9 +928,9 @@ def test_add_git_constraint_old_installer(app, repo, installer, old_tester): } -def test_add_git_constraint_with_poetry_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("pendulum", "1.4.4")) - +def test_add_git_constraint_with_poetry_old_installer( + repo_with_packages, installer, old_tester +): old_tester.execute("git+https://github.com/demo/pyproject-demo.git") expected = """\ @@ -999,11 +951,9 @@ def test_add_git_constraint_with_poetry_old_installer(app, repo, installer, old_ assert len(installer.installs) == 2 -def test_add_git_constraint_with_extras_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - repo.add_package(get_package("tomlkit", "0.5.5")) - +def test_add_git_constraint_with_extras_old_installer( + app, repo_with_packages, installer, old_tester +): old_tester.execute("git+https://github.com/demo/demo.git[foo,bar]") expected = """\ @@ -1034,10 +984,9 @@ def test_add_git_constraint_with_extras_old_installer(app, repo, installer, old_ } -def test_add_git_ssh_constraint_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - +def test_add_git_ssh_constraint_old_installer( + app, repo_with_packages, installer, old_tester +): old_tester.execute("git+ssh://git@github.com/demo/demo.git@develop") expected = """\ @@ -1067,14 +1016,11 @@ def test_add_git_ssh_constraint_old_installer(app, repo, installer, old_tester): def test_add_directory_constraint_old_installer( - app, repo, installer, mocker, old_tester + app, repo_with_packages, installer, mocker, old_tester ): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - path = "../git/github.com/demo/demo" old_tester.execute("{}".format(path)) @@ -1104,13 +1050,11 @@ def test_add_directory_constraint_old_installer( def test_add_directory_with_poetry_old_installer( - app, repo, installer, mocker, old_tester + app, repo_with_packages, installer, mocker, old_tester ): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../git/github.com/demo/pyproject-demo" old_tester.execute("{}".format(path)) @@ -1135,13 +1079,11 @@ def test_add_directory_with_poetry_old_installer( def test_add_file_constraint_wheel_old_installer( - app, repo, installer, mocker, old_tester + app, repo_with_packages, installer, mocker, old_tester ): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" old_tester.execute("{}".format(path)) @@ -1173,13 +1115,11 @@ def test_add_file_constraint_wheel_old_installer( def test_add_file_constraint_sdist_old_installer( - app, repo, installer, mocker, old_tester + app, repo_with_packages, installer, mocker, old_tester ): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - path = "../distributions/demo-0.1.0.tar.gz" old_tester.execute("{}".format(path)) @@ -1251,13 +1191,11 @@ def test_add_constraint_with_extras_option_old_installer( def test_add_url_constraint_wheel_old_installer( - app, repo, installer, mocker, old_tester + app, repo_with_packages, installer, mocker, old_tester ): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." - repo.add_package(get_package("pendulum", "1.4.4")) - old_tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl" ) @@ -1288,12 +1226,8 @@ def test_add_url_constraint_wheel_old_installer( def test_add_url_constraint_wheel_with_extras_old_installer( - app, repo, installer, old_tester + app, repo_with_packages, installer, old_tester ): - repo.add_package(get_package("pendulum", "1.4.4")) - repo.add_package(get_package("cleo", "0.6.5")) - repo.add_package(get_package("tomlkit", "0.5.5")) - old_tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl[foo,bar]" ) @@ -1326,12 +1260,9 @@ def test_add_url_constraint_wheel_with_extras_old_installer( } -def test_add_constraint_with_python_old_installer(app, repo, installer, old_tester): - cachy2 = get_package("cachy", "0.2.0") - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - +def test_add_constraint_with_python_old_installer( + app, repo_with_packages, installer, old_tester +): old_tester.execute("cachy=0.2.0 --python >=2.7") expected = """\ @@ -1357,16 +1288,11 @@ def test_add_constraint_with_python_old_installer(app, repo, installer, old_test def test_add_constraint_with_platform_old_installer( - app, repo, installer, env, old_tester + app, repo_with_packages, installer, env, old_tester ): platform = sys.platform env._platform = platform - cachy2 = get_package("cachy", "0.2.0") - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - old_tester.execute("cachy=0.2.0 --platform {} -vvv".format(platform)) expected = """\ @@ -1394,7 +1320,9 @@ def test_add_constraint_with_platform_old_installer( } -def test_add_constraint_with_source_old_installer(app, poetry, installer, old_tester): +def test_add_constraint_with_source_old_installer( + app, repo, poetry, installer, old_tester +): repo = LegacyRepository(name="my-index", url="https://my-index.fake") repo.add_package(get_package("cachy", "0.2.0")) repo._cache.store("matches").put("cachy:0.2.0", [Version.parse("0.2.0")], 5) @@ -1428,7 +1356,7 @@ def test_add_constraint_with_source_old_installer(app, poetry, installer, old_te } -def test_add_constraint_with_source_that_does_not_exist_old_installer(app, old_tester): +def test_add_constraint_with_source_that_does_not_exist_old_installer(old_tester): with pytest.raises(ValueError) as e: old_tester.execute("foo --source i-dont-exist") @@ -1453,11 +1381,8 @@ def test_add_constraint_not_found_with_source_old_installer( def test_add_to_section_that_does_no_exist_yet_old_installer( - app, repo, installer, old_tester + app, repo_with_packages, installer, old_tester ): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) - old_tester.execute("cachy --dev") expected = """\ @@ -1484,11 +1409,8 @@ def test_add_to_section_that_does_no_exist_yet_old_installer( def test_add_should_not_select_prereleases_old_installer( - app, repo, installer, old_tester + app, repo_with_packages, installer, old_tester ): - repo.add_package(get_package("pyyaml", "3.13")) - repo.add_package(get_package("pyyaml", "4.2b2")) - old_tester.execute("pyyaml") expected = """\ @@ -1515,7 +1437,7 @@ def test_add_should_not_select_prereleases_old_installer( def test_add_should_skip_when_adding_existing_package_with_no_constraint_old_installer( - app, repo, installer, old_tester + app, repo, old_tester ): content = app.poetry.file.read() content["tool"]["poetry"]["dependencies"]["foo"] = "^1.0" @@ -1538,7 +1460,7 @@ def test_add_should_skip_when_adding_existing_package_with_no_constraint_old_ins def test_add_should_work_when_adding_existing_package_with_latest_constraint_old_installer( - app, repo, installer, old_tester + app, repo, old_tester ): content = app.poetry.file.read() content["tool"]["poetry"]["dependencies"]["foo"] = "^1.0" @@ -1570,7 +1492,7 @@ def test_add_should_work_when_adding_existing_package_with_latest_constraint_old def test_add_chooses_prerelease_if_only_prereleases_are_available_old_installer( - app, repo, installer, old_tester + repo, old_tester ): repo.add_package(get_package("foo", "1.2.3b0")) repo.add_package(get_package("foo", "1.2.3b1")) @@ -1593,7 +1515,7 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available_old_installer( assert expected in old_tester.io.fetch_output() -def test_add_preferes_stable_releases_old_installer(app, repo, installer, old_tester): +def test_add_preferes_stable_releases_old_installer(repo, old_tester): repo.add_package(get_package("foo", "1.2.3")) repo.add_package(get_package("foo", "1.2.4b1")) @@ -1615,9 +1537,7 @@ def test_add_preferes_stable_releases_old_installer(app, repo, installer, old_te assert expected in old_tester.io.fetch_output() -def test_add_with_lock_old_installer(app, repo, installer, old_tester): - repo.add_package(get_package("cachy", "0.2.0")) - +def test_add_with_lock_old_installer(repo_with_packages, old_tester): old_tester.execute("cachy --lock") expected = """\ From d61133faea0909ace7b031161e1967b9f43997f0 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Tue, 13 Oct 2020 20:24:20 -0400 Subject: [PATCH 5/5] Making repo_add_default_packages fixture autouse --- tests/console/commands/test_add.py | 252 +++++++++++------------------ 1 file changed, 93 insertions(+), 159 deletions(-) diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index f5bdc9ed53a..654bd82f243 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -24,10 +24,20 @@ def old_tester(tester): return tester -@pytest.fixture() -def repo_with_packages(repo): - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(get_package("cachy", "0.2.0")) +@pytest.fixture(autouse=True) +def repo_add_default_packages(repo): + repo.add_package(get_package("msgpack-python", "0.5.6")) + + cachy010 = get_package("cachy", "0.1.0") + cachy010.extras = {"msgpack": [get_dependency("msgpack-python")]} + cachy010.requires = [get_dependency("msgpack-python", ">=0.5 <0.6", optional=True)] + repo.add_package(cachy010) + + cachy020 = get_package("cachy", "0.2.0") + cachy020.extras = {"msgpack": [get_dependency("msgpack-python")]} + cachy020.requires = [get_dependency("msgpack-python", ">=0.5 <0.6")] + repo.add_package(cachy020) + repo.add_package(get_package("pendulum", "1.4.4")) repo.add_package(get_package("cleo", "0.6.5")) repo.add_package(get_package("tomlkit", "0.5.5")) @@ -35,7 +45,7 @@ def repo_with_packages(repo): repo.add_package(get_package("pyyaml", "4.2b2")) -def test_add_no_constraint(app, repo_with_packages, tester): +def test_add_no_constraint(app, tester): tester.execute("cachy") expected = """\ @@ -46,13 +56,14 @@ def test_add_no_constraint(app, repo_with_packages, tester): Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ assert expected == tester.io.fetch_output() - assert 1 == tester._command.installer.executor.installations_count + assert 2 == tester._command.installer.executor.installations_count content = app.poetry.file.read()["tool"]["poetry"] @@ -60,7 +71,7 @@ def test_add_no_constraint(app, repo_with_packages, tester): assert content["dependencies"]["cachy"] == "^0.2.0" -def test_add_equal_constraint(repo_with_packages, tester): +def test_add_equal_constraint(tester): tester.execute("cachy==0.1.0") expected = """\ @@ -79,7 +90,7 @@ def test_add_equal_constraint(repo_with_packages, tester): assert 1 == tester._command.installer.executor.installations_count -def test_add_greater_constraint(repo_with_packages, tester): +def test_add_greater_constraint(tester): tester.execute("cachy>=0.1.0") expected = """\ @@ -89,25 +100,17 @@ def test_add_greater_constraint(repo_with_packages, tester): Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ assert expected == tester.io.fetch_output() - assert 1 == tester._command.installer.executor.installations_count - + assert 2 == tester._command.installer.executor.installations_count -def test_add_constraint_with_extras(repo, tester): - cachy1 = get_package("cachy", "0.1.0") - cachy1.extras = {"msgpack": [get_dependency("msgpack-python")]} - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) - cachy1.requires = [msgpack_dep] - - repo.add_package(get_package("cachy", "0.2.0")) - repo.add_package(cachy1) - repo.add_package(get_package("msgpack-python", "0.5.3")) +def test_add_constraint_with_extras(tester): tester.execute("cachy[msgpack]>=0.1.0,<0.2.0") expected = """\ @@ -119,7 +122,7 @@ def test_add_constraint_with_extras(repo, tester): Package operations: 2 installs, 0 updates, 0 removals - • Installing msgpack-python (0.5.3) + • Installing msgpack-python (0.5.6) • Installing cachy (0.1.0) """ @@ -127,15 +130,7 @@ def test_add_constraint_with_extras(repo, tester): assert 2 == tester._command.installer.executor.installations_count -def test_add_constraint_dependencies(repo, tester): - cachy2 = get_package("cachy", "0.2.0") - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6") - cachy2.requires = [msgpack_dep] - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - repo.add_package(get_package("msgpack-python", "0.5.3")) - +def test_add_constraint_dependencies(tester): tester.execute("cachy=0.2.0") expected = """\ @@ -147,7 +142,7 @@ def test_add_constraint_dependencies(repo, tester): Package operations: 2 installs, 0 updates, 0 removals - • Installing msgpack-python (0.5.3) + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ @@ -155,7 +150,7 @@ def test_add_constraint_dependencies(repo, tester): assert 2 == tester._command.installer.executor.installations_count -def test_add_git_constraint(app, repo_with_packages, tester, tmp_venv): +def test_add_git_constraint(app, tester, tmp_venv): tester._command.set_env(tmp_venv) tester.execute("git+https://github.com/demo/demo.git") @@ -184,7 +179,7 @@ def test_add_git_constraint(app, repo_with_packages, tester, tmp_venv): } -def test_add_git_constraint_with_poetry(repo_with_packages, tester, tmp_venv): +def test_add_git_constraint_with_poetry(tester, tmp_venv): tester._command.set_env(tmp_venv) tester.execute("git+https://github.com/demo/pyproject-demo.git") @@ -206,7 +201,7 @@ def test_add_git_constraint_with_poetry(repo_with_packages, tester, tmp_venv): assert 2 == tester._command.installer.executor.installations_count -def test_add_git_constraint_with_extras(app, repo_with_packages, tester, tmp_venv): +def test_add_git_constraint_with_extras(app, tester, tmp_venv): tester._command.set_env(tmp_venv) tester.execute("git+https://github.com/demo/demo.git[foo,bar]") @@ -238,7 +233,7 @@ def test_add_git_constraint_with_extras(app, repo_with_packages, tester, tmp_ven } -def test_add_git_ssh_constraint(app, repo_with_packages, tester, tmp_venv): +def test_add_git_ssh_constraint(app, tester, tmp_venv): tester._command.set_env(tmp_venv) tester.execute("git+ssh://git@github.com/demo/demo.git@develop") @@ -268,7 +263,7 @@ def test_add_git_ssh_constraint(app, repo_with_packages, tester, tmp_venv): } -def test_add_directory_constraint(app, repo_with_packages, tester, mocker): +def test_add_directory_constraint(app, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__).parent @@ -299,7 +294,7 @@ def test_add_directory_constraint(app, repo_with_packages, tester, mocker): assert content["dependencies"]["demo"] == {"path": "../git/github.com/demo/demo"} -def test_add_directory_with_poetry(app, repo_with_packages, tester, mocker): +def test_add_directory_with_poetry(app, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -325,7 +320,7 @@ def test_add_directory_with_poetry(app, repo_with_packages, tester, mocker): assert 2 == tester._command.installer.executor.installations_count -def test_add_file_constraint_wheel(app, repo_with_packages, tester, mocker, poetry): +def test_add_file_constraint_wheel(app, tester, mocker, poetry): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = poetry.file.parent @@ -358,7 +353,7 @@ def test_add_file_constraint_wheel(app, repo_with_packages, tester, mocker, poet } -def test_add_file_constraint_sdist(app, repo_with_packages, tester, mocker): +def test_add_file_constraint_sdist(app, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -391,16 +386,7 @@ def test_add_file_constraint_sdist(app, repo_with_packages, tester, mocker): } -def test_add_constraint_with_extras_option(app, repo, tester): - cachy2 = get_package("cachy", "0.2.0") - cachy2.extras = {"msgpack": [get_dependency("msgpack-python")]} - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) - cachy2.requires = [msgpack_dep] - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - repo.add_package(get_package("msgpack-python", "0.5.3")) - +def test_add_constraint_with_extras_option(app, tester): tester.execute("cachy=0.2.0 --extras msgpack") expected = """\ @@ -412,7 +398,7 @@ def test_add_constraint_with_extras_option(app, repo, tester): Package operations: 2 installs, 0 updates, 0 removals - • Installing msgpack-python (0.5.3) + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ @@ -428,7 +414,7 @@ def test_add_constraint_with_extras_option(app, repo, tester): } -def test_add_url_constraint_wheel(app, repo_with_packages, tester, mocker): +def test_add_url_constraint_wheel(app, tester, mocker): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -460,7 +446,7 @@ def test_add_url_constraint_wheel(app, repo_with_packages, tester, mocker): } -def test_add_url_constraint_wheel_with_extras(app, repo_with_packages, tester): +def test_add_url_constraint_wheel_with_extras(app, tester): tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl[foo,bar]" ) @@ -494,7 +480,7 @@ def test_add_url_constraint_wheel_with_extras(app, repo_with_packages, tester): } -def test_add_constraint_with_python(app, repo_with_packages, tester): +def test_add_constraint_with_python(app, tester): tester.execute("cachy=0.2.0 --python >=2.7") expected = """\ @@ -504,13 +490,14 @@ def test_add_constraint_with_python(app, repo_with_packages, tester): Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ assert expected == tester.io.fetch_output() - assert 1 == tester._command.installer.executor.installations_count + assert 2 == tester._command.installer.executor.installations_count content = app.poetry.file.read()["tool"]["poetry"] @@ -518,7 +505,7 @@ def test_add_constraint_with_python(app, repo_with_packages, tester): assert content["dependencies"]["cachy"] == {"version": "0.2.0", "python": ">=2.7"} -def test_add_constraint_with_platform(app, repo_with_packages, tester, env): +def test_add_constraint_with_platform(app, tester, env): platform = sys.platform env._platform = platform @@ -531,13 +518,14 @@ def test_add_constraint_with_platform(app, repo_with_packages, tester, env): Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ assert expected == tester.io.fetch_output() - assert 1 == tester._command.installer.executor.installations_count + assert 2 == tester._command.installer.executor.installations_count content = app.poetry.file.read()["tool"]["poetry"] @@ -603,7 +591,7 @@ def test_add_constraint_not_found_with_source(poetry, mocker, tester): assert "Could not find a matching version of package cachy" == str(e.value) -def test_add_to_section_that_does_no_exist_yet(app, repo_with_packages, tester): +def test_add_to_section_that_does_no_exist_yet(app, tester): tester.execute("cachy --dev") expected = """\ @@ -614,13 +602,14 @@ def test_add_to_section_that_does_no_exist_yet(app, repo_with_packages, tester): Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + • Installing msgpack-python (0.5.6) • Installing cachy (0.2.0) """ assert expected == tester.io.fetch_output() - assert 1 == tester._command.installer.executor.installations_count + assert 2 == tester._command.installer.executor.installations_count content = app.poetry.file.read()["tool"]["poetry"] @@ -628,7 +617,7 @@ def test_add_to_section_that_does_no_exist_yet(app, repo_with_packages, tester): assert content["dev-dependencies"]["cachy"] == "^0.2.0" -def test_add_should_not_select_prereleases(app, repo_with_packages, tester): +def test_add_should_not_select_prereleases(app, tester): tester.execute("pyyaml") expected = """\ @@ -751,7 +740,7 @@ def test_add_prefers_stable_releases(repo, tester): assert expected in tester.io.fetch_output() -def test_add_with_lock(app, repo_with_packages, tester): +def test_add_with_lock(app, tester): content_hash = app.poetry.locker._get_content_hash() tester.execute("cachy --lock") @@ -769,9 +758,7 @@ def test_add_with_lock(app, repo_with_packages, tester): assert content_hash != app.poetry.locker.lock_data["metadata"]["content-hash"] -def test_add_no_constraint_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_no_constraint_old_installer(app, installer, old_tester): old_tester.execute("cachy") expected = """\ @@ -782,14 +769,15 @@ def test_add_no_constraint_old_installer( Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ assert expected == old_tester.io.fetch_output() - assert len(installer.installs) == 1 + assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] @@ -797,7 +785,7 @@ def test_add_no_constraint_old_installer( assert content["dependencies"]["cachy"] == "^0.2.0" -def test_add_equal_constraint_old_installer(repo_with_packages, installer, old_tester): +def test_add_equal_constraint_old_installer(installer, old_tester): old_tester.execute("cachy==0.1.0") expected = """\ @@ -817,9 +805,7 @@ def test_add_equal_constraint_old_installer(repo_with_packages, installer, old_t assert len(installer.installs) == 1 -def test_add_greater_constraint_old_installer( - repo_with_packages, installer, old_tester -): +def test_add_greater_constraint_old_installer(installer, old_tester): old_tester.execute("cachy>=0.1.0") expected = """\ @@ -829,26 +815,18 @@ def test_add_greater_constraint_old_installer( Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ assert expected == old_tester.io.fetch_output() - assert len(installer.installs) == 1 - - -def test_add_constraint_with_extras_old_installer(repo, installer, old_tester): - cachy1 = get_package("cachy", "0.1.0") - cachy1.extras = {"msgpack": [get_dependency("msgpack-python")]} - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) - cachy1.requires = [msgpack_dep] + assert len(installer.installs) == 2 - repo.add_package(get_package("cachy", "0.2.0")) - repo.add_package(cachy1) - repo.add_package(get_package("msgpack-python", "0.5.3")) +def test_add_constraint_with_extras_old_installer(installer, old_tester): old_tester.execute("cachy[msgpack]>=0.1.0,<0.2.0") expected = """\ @@ -860,7 +838,7 @@ def test_add_constraint_with_extras_old_installer(repo, installer, old_tester): Package operations: 2 installs, 0 updates, 0 removals - - Installing msgpack-python (0.5.3) + - Installing msgpack-python (0.5.6) - Installing cachy (0.1.0) """ @@ -869,15 +847,7 @@ def test_add_constraint_with_extras_old_installer(repo, installer, old_tester): assert len(installer.installs) == 2 -def test_add_constraint_dependencies_old_installer(repo, installer, old_tester): - cachy2 = get_package("cachy", "0.2.0") - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6") - cachy2.requires = [msgpack_dep] - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - repo.add_package(get_package("msgpack-python", "0.5.3")) - +def test_add_constraint_dependencies_old_installer(installer, old_tester): old_tester.execute("cachy=0.2.0") expected = """\ @@ -889,7 +859,7 @@ def test_add_constraint_dependencies_old_installer(repo, installer, old_tester): Package operations: 2 installs, 0 updates, 0 removals - - Installing msgpack-python (0.5.3) + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ @@ -898,9 +868,7 @@ def test_add_constraint_dependencies_old_installer(repo, installer, old_tester): assert len(installer.installs) == 2 -def test_add_git_constraint_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_git_constraint_old_installer(app, installer, old_tester): old_tester.execute("git+https://github.com/demo/demo.git") expected = """\ @@ -928,9 +896,7 @@ def test_add_git_constraint_old_installer( } -def test_add_git_constraint_with_poetry_old_installer( - repo_with_packages, installer, old_tester -): +def test_add_git_constraint_with_poetry_old_installer(installer, old_tester): old_tester.execute("git+https://github.com/demo/pyproject-demo.git") expected = """\ @@ -951,9 +917,7 @@ def test_add_git_constraint_with_poetry_old_installer( assert len(installer.installs) == 2 -def test_add_git_constraint_with_extras_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_git_constraint_with_extras_old_installer(app, installer, old_tester): old_tester.execute("git+https://github.com/demo/demo.git[foo,bar]") expected = """\ @@ -984,9 +948,7 @@ def test_add_git_constraint_with_extras_old_installer( } -def test_add_git_ssh_constraint_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_git_ssh_constraint_old_installer(app, installer, old_tester): old_tester.execute("git+ssh://git@github.com/demo/demo.git@develop") expected = """\ @@ -1015,9 +977,7 @@ def test_add_git_ssh_constraint_old_installer( } -def test_add_directory_constraint_old_installer( - app, repo_with_packages, installer, mocker, old_tester -): +def test_add_directory_constraint_old_installer(app, installer, mocker, old_tester): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -1049,9 +1009,7 @@ def test_add_directory_constraint_old_installer( assert content["dependencies"]["demo"] == {"path": "../git/github.com/demo/demo"} -def test_add_directory_with_poetry_old_installer( - app, repo_with_packages, installer, mocker, old_tester -): +def test_add_directory_with_poetry_old_installer(app, installer, mocker, old_tester): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -1078,9 +1036,7 @@ def test_add_directory_with_poetry_old_installer( assert len(installer.installs) == 2 -def test_add_file_constraint_wheel_old_installer( - app, repo_with_packages, installer, mocker, old_tester -): +def test_add_file_constraint_wheel_old_installer(app, installer, mocker, old_tester): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -1114,9 +1070,7 @@ def test_add_file_constraint_wheel_old_installer( } -def test_add_file_constraint_sdist_old_installer( - app, repo_with_packages, installer, mocker, old_tester -): +def test_add_file_constraint_sdist_old_installer(app, installer, mocker, old_tester): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -1150,18 +1104,7 @@ def test_add_file_constraint_sdist_old_installer( } -def test_add_constraint_with_extras_option_old_installer( - app, repo, installer, old_tester -): - cachy2 = get_package("cachy", "0.2.0") - cachy2.extras = {"msgpack": [get_dependency("msgpack-python")]} - msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) - cachy2.requires = [msgpack_dep] - - repo.add_package(get_package("cachy", "0.1.0")) - repo.add_package(cachy2) - repo.add_package(get_package("msgpack-python", "0.5.3")) - +def test_add_constraint_with_extras_option_old_installer(app, installer, old_tester): old_tester.execute("cachy=0.2.0 --extras msgpack") expected = """\ @@ -1173,7 +1116,7 @@ def test_add_constraint_with_extras_option_old_installer( Package operations: 2 installs, 0 updates, 0 removals - - Installing msgpack-python (0.5.3) + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ @@ -1190,9 +1133,7 @@ def test_add_constraint_with_extras_option_old_installer( } -def test_add_url_constraint_wheel_old_installer( - app, repo_with_packages, installer, mocker, old_tester -): +def test_add_url_constraint_wheel_old_installer(app, installer, mocker, old_tester): p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) / ".." @@ -1225,9 +1166,7 @@ def test_add_url_constraint_wheel_old_installer( } -def test_add_url_constraint_wheel_with_extras_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_url_constraint_wheel_with_extras_old_installer(app, installer, old_tester): old_tester.execute( "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl[foo,bar]" ) @@ -1260,9 +1199,7 @@ def test_add_url_constraint_wheel_with_extras_old_installer( } -def test_add_constraint_with_python_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_constraint_with_python_old_installer(app, installer, old_tester): old_tester.execute("cachy=0.2.0 --python >=2.7") expected = """\ @@ -1272,14 +1209,15 @@ def test_add_constraint_with_python_old_installer( Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ assert expected == old_tester.io.fetch_output() - assert len(installer.installs) == 1 + assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] @@ -1287,9 +1225,7 @@ def test_add_constraint_with_python_old_installer( assert content["dependencies"]["cachy"] == {"version": "0.2.0", "python": ">=2.7"} -def test_add_constraint_with_platform_old_installer( - app, repo_with_packages, installer, env, old_tester -): +def test_add_constraint_with_platform_old_installer(app, installer, env, old_tester): platform = sys.platform env._platform = platform @@ -1302,14 +1238,15 @@ def test_add_constraint_with_platform_old_installer( Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ assert expected == old_tester.io.fetch_output() - assert len(installer.installs) == 1 + assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] @@ -1363,9 +1300,7 @@ def test_add_constraint_with_source_that_does_not_exist_old_installer(old_tester assert 'Repository "i-dont-exist" does not exist.' == str(e.value) -def test_add_constraint_not_found_with_source_old_installer( - app, poetry, mocker, old_tester -): +def test_add_constraint_not_found_with_source_old_installer(poetry, mocker, old_tester): repo = LegacyRepository(name="my-index", url="https://my-index.fake") mocker.patch.object(repo, "find_packages", return_value=[]) @@ -1381,7 +1316,7 @@ def test_add_constraint_not_found_with_source_old_installer( def test_add_to_section_that_does_no_exist_yet_old_installer( - app, repo_with_packages, installer, old_tester + app, installer, old_tester ): old_tester.execute("cachy --dev") @@ -1393,14 +1328,15 @@ def test_add_to_section_that_does_no_exist_yet_old_installer( Writing lock file -Package operations: 1 install, 0 updates, 0 removals +Package operations: 2 installs, 0 updates, 0 removals + - Installing msgpack-python (0.5.6) - Installing cachy (0.2.0) """ assert expected == old_tester.io.fetch_output() - assert len(installer.installs) == 1 + assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] @@ -1408,9 +1344,7 @@ def test_add_to_section_that_does_no_exist_yet_old_installer( assert content["dev-dependencies"]["cachy"] == "^0.2.0" -def test_add_should_not_select_prereleases_old_installer( - app, repo_with_packages, installer, old_tester -): +def test_add_should_not_select_prereleases_old_installer(app, installer, old_tester): old_tester.execute("pyyaml") expected = """\ @@ -1537,7 +1471,7 @@ def test_add_preferes_stable_releases_old_installer(repo, old_tester): assert expected in old_tester.io.fetch_output() -def test_add_with_lock_old_installer(repo_with_packages, old_tester): +def test_add_with_lock_old_installer(old_tester): old_tester.execute("cachy --lock") expected = """\