diff --git a/tests/console/commands/env/conftest.py b/tests/console/commands/env/conftest.py index f118b5f05f1..4f613248cc0 100644 --- a/tests/console/commands/env/conftest.py +++ b/tests/console/commands/env/conftest.py @@ -20,7 +20,7 @@ def venv_name(app: PoetryTestApplication) -> str: return EnvManager.generate_env_name( app.poetry.package.name, - str(app.poetry.file.path.parent), + str(app.poetry.file.parent), ) @@ -58,7 +58,7 @@ def venvs_in_cache_dirs( @pytest.fixture def venvs_in_project_dir(app: PoetryTestApplication) -> Iterator[Path]: os.environ.pop("VIRTUAL_ENV", None) - venv_dir = app.poetry.file.path.parent.joinpath(".venv") + venv_dir = app.poetry.file.parent.joinpath(".venv") venv_dir.mkdir(exist_ok=True) app.poetry.config.merge({"virtualenvs": {"in-project": True}}) @@ -71,7 +71,7 @@ def venvs_in_project_dir(app: PoetryTestApplication) -> Iterator[Path]: @pytest.fixture def venvs_in_project_dir_none(app: PoetryTestApplication) -> Iterator[Path]: os.environ.pop("VIRTUAL_ENV", None) - venv_dir = app.poetry.file.path.parent.joinpath(".venv") + venv_dir = app.poetry.file.parent.joinpath(".venv") venv_dir.mkdir(exist_ok=True) app.poetry.config.merge({"virtualenvs": {"in-project": None}}) @@ -84,7 +84,7 @@ def venvs_in_project_dir_none(app: PoetryTestApplication) -> Iterator[Path]: @pytest.fixture def venvs_in_project_dir_false(app: PoetryTestApplication) -> Iterator[Path]: os.environ.pop("VIRTUAL_ENV", None) - venv_dir = app.poetry.file.path.parent.joinpath(".venv") + venv_dir = app.poetry.file.parent.joinpath(".venv") venv_dir.mkdir(exist_ok=True) app.poetry.config.merge({"virtualenvs": {"in-project": False}}) diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index 33d7848b482..25d3eb49fed 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -15,7 +15,6 @@ from poetry.console.commands.installer_command import InstallerCommand from poetry.puzzle.exceptions import SolverProblemError from poetry.repositories.legacy_repository import LegacyRepository -from tests.helpers import TestLocker from tests.helpers import get_dependency from tests.helpers import get_package @@ -1507,36 +1506,3 @@ def test_add_extras_only_accepts_one_package( str(e.value) == "You can only specify one package when using the --extras option" ) - - -@pytest.mark.parametrize("command", ["foo", "foo --lock"]) -@pytest.mark.parametrize( - ("locked", "expected_docker"), [(True, "4.3.1"), (False, "4.3.2")] -) -def test_add_does_not_update_locked_dependencies( - repo: TestRepository, - poetry_with_up_to_date_lockfile: Poetry, - tester: CommandTester, - command_tester_factory: CommandTesterFactory, - command: str, - locked: bool, - expected_docker: str, -) -> None: - assert isinstance(poetry_with_up_to_date_lockfile.locker, TestLocker) - poetry_with_up_to_date_lockfile.locker.locked(locked) - tester = command_tester_factory("add", poetry=poetry_with_up_to_date_lockfile) - docker_locked = get_package("docker", "4.3.1") - docker_new = get_package("docker", "4.3.2") - docker_dep = get_dependency("docker", ">=4.0.0") - foo = get_package("foo", "0.1.0") - foo.add_dependency(docker_dep) - for package in docker_locked, docker_new, foo: - repo.add_package(package) - - tester.execute(command) - - lock_data = poetry_with_up_to_date_lockfile.locker.lock_data - docker_locked_after_command = next( - p for p in lock_data["package"] if p["name"] == "docker" - ) - assert docker_locked_after_command["version"] == expected_docker diff --git a/tests/console/commands/test_install.py b/tests/console/commands/test_install.py index 2e3b34ac5b5..bf3c819552a 100644 --- a/tests/console/commands/test_install.py +++ b/tests/console/commands/test_install.py @@ -419,10 +419,9 @@ def test_install_logs_output_decorated( @pytest.mark.parametrize("options", ["", "--without dev"]) @pytest.mark.parametrize( - "project", - ["missing_directory_dependency_from_group", "missing_file_dependency_from_group"], + "project", ["missing_directory_dependency", "missing_file_dependency"] ) -def test_install__dependency_does_not_exist( +def test_install_path_dependency_does_not_exist( command_tester_factory: CommandTesterFactory, project_factory: ProjectFactory, fixture_dir: FixtureDirGetter, @@ -438,3 +437,23 @@ def test_install__dependency_does_not_exist( else: with pytest.raises(ValueError, match="does not exist"): tester.execute(options) + + +@pytest.mark.parametrize("options", ["", "--no-directory"]) +def test_install_missing_directory_dependency_with_no_directory( + command_tester_factory: CommandTesterFactory, + project_factory: ProjectFactory, + fixture_dir: FixtureDirGetter, + options: str, +) -> None: + poetry = _project_factory( + "missing_directory_dependency", project_factory, fixture_dir + ) + assert isinstance(poetry.locker, TestLocker) + poetry.locker.locked(True) + tester = command_tester_factory("install", poetry=poetry) + if options: + tester.execute(options) + else: + with pytest.raises(ValueError, match="does not exist"): + tester.execute(options) diff --git a/tests/console/commands/test_lock.py b/tests/console/commands/test_lock.py index ed832eec76f..7a910caccf7 100644 --- a/tests/console/commands/test_lock.py +++ b/tests/console/commands/test_lock.py @@ -208,7 +208,7 @@ def test_lock_no_update_path_dependencies( @pytest.mark.parametrize( "project", ["missing_directory_dependency", "missing_file_dependency"] ) -def test_lock_path_dependency_does_not_exist_and_was_removed_from_pyproject( +def test_lock_path_dependency_does_not_exist( command_tester_factory: CommandTesterFactory, project_factory: ProjectFactory, fixture_dir: FixtureDirGetter, diff --git a/tests/console/commands/test_remove.py b/tests/console/commands/test_remove.py index 8cb0650e776..4826f0ae57a 100644 --- a/tests/console/commands/test_remove.py +++ b/tests/console/commands/test_remove.py @@ -10,7 +10,6 @@ from poetry.core.packages.package import Package from poetry.factory import Factory -from tests.helpers import TestLocker from tests.helpers import get_package @@ -34,16 +33,12 @@ def poetry_with_up_to_date_lockfile( ) -> Poetry: source = fixture_dir("up_to_date_lock") - poetry = project_factory( + return project_factory( name="foobar", pyproject_content=(source / "pyproject.toml").read_text(encoding="utf-8"), poetry_lock_content=(source / "poetry.lock").read_text(encoding="utf-8"), ) - assert isinstance(poetry.locker, TestLocker) - poetry.locker.locked(True) - return poetry - @pytest.fixture() def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: @@ -54,6 +49,7 @@ def test_remove_without_specific_group_removes_from_all_groups( tester: CommandTester, app: PoetryTestApplication, repo: TestRepository, + command_tester_factory: CommandTesterFactory, installed: Repository, ) -> None: """ @@ -112,6 +108,7 @@ def test_remove_without_specific_group_removes_from_specific_groups( tester: CommandTester, app: PoetryTestApplication, repo: TestRepository, + command_tester_factory: CommandTesterFactory, installed: Repository, ) -> None: """ @@ -169,6 +166,7 @@ def test_remove_does_not_live_empty_groups( tester: CommandTester, app: PoetryTestApplication, repo: TestRepository, + command_tester_factory: CommandTesterFactory, installed: Repository, ) -> None: """ @@ -215,6 +213,7 @@ def test_remove_canonicalized_named_removes_dependency_correctly( tester: CommandTester, app: PoetryTestApplication, repo: TestRepository, + command_tester_factory: CommandTesterFactory, installed: Repository, ) -> None: """ @@ -309,47 +308,3 @@ def test_remove_with_dry_run_keep_files_intact( assert ( poetry_with_up_to_date_lockfile._locker.lock_data == original_lockfile_content ) - - -def test_remove_performs_uninstall_op( - poetry_with_up_to_date_lockfile: Poetry, - command_tester_factory: CommandTesterFactory, - installed: Repository, -) -> None: - installed.add_package(get_package("docker", "4.3.1")) - tester = command_tester_factory("remove", poetry=poetry_with_up_to_date_lockfile) - - tester.execute("docker") - - expected = """\ -Updating dependencies -Resolving dependencies... - -Package operations: 0 installs, 0 updates, 1 removal - - • Removing docker (4.3.1) - -Writing lock file -""" - - assert tester.io.fetch_output() == expected - - -def test_remove_with_lock_does_not_perform_uninstall_op( - poetry_with_up_to_date_lockfile: Poetry, - command_tester_factory: CommandTesterFactory, - installed: Repository, -) -> None: - installed.add_package(get_package("docker", "4.3.1")) - tester = command_tester_factory("remove", poetry=poetry_with_up_to_date_lockfile) - - tester.execute("docker --lock") - - expected = """\ -Updating dependencies -Resolving dependencies... - -Writing lock file -""" - - assert tester.io.fetch_output() == expected diff --git a/tests/fixtures/missing_directory_dependency/poetry.lock b/tests/fixtures/missing_directory_dependency/poetry.lock index 663d2c6efd0..5fd7b6aeb59 100644 --- a/tests/fixtures/missing_directory_dependency/poetry.lock +++ b/tests/fixtures/missing_directory_dependency/poetry.lock @@ -1,110 +1,18 @@ -# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. +# This file is automatically @generated by Poetry and should not be changed by hand. [[package]] name = "missing" -version = "1.0.0" -description = "This is a description" -category = "main" +version = "1.2.3" +description = "" optional = false python-versions = "*" files = [] develop = false -[package.dependencies] -pendulum = "1.4.4" - [package.source] type = "directory" url = "missing" -[[package]] -name = "pendulum" -version = "1.4.4" -description = "Python datetimes made easy." -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "pendulum-1.4.4-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:501670f3b1d581395ec4094aff7c13dca6b699d1810cf15c446433b9e736eb4a"}, - {file = "pendulum-1.4.4-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:b9a7ef02ad6255292f35218c595f8be35e0ca3c7ac19e633ff2de96480f26ab3"}, - {file = "pendulum-1.4.4-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3d8b280a903fb25bdba258203bbcd0533c5c04a65878f6e0700931dedd2bae72"}, - {file = "pendulum-1.4.4-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f30fb1149e4f67b3aaa9eae874dca7bbf49788ac121d702486f5b9fe549e7920"}, - {file = "pendulum-1.4.4-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:4c945ed6a3b0afab8c2f1b1e3e26bb23ad0a9be6f201604111a8217cea78e7ab"}, - {file = "pendulum-1.4.4-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:253983de6d64a01909c2524e4ab27febd0d3987d001ea6ab93a7b945fdc0e6c6"}, - {file = "pendulum-1.4.4-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:76ee830b4b57a3f8244a228505bf9c55285cc92f1a200c8578b0ca54f8185861"}, - {file = "pendulum-1.4.4.tar.gz", hash = "sha256:601e52cb0425e94b1784b6613a9085e0066ae1fa1915d18771884b67e93cac5c"}, -] - -[package.dependencies] -python-dateutil = ">=2.6.0.0,<3.0.0.0" -pytzdata = ">=2018.3.0.0" -tzlocal = ">=1.5.0.0,<2.0.0.0" - -[[package]] -name = "python-dateutil" -version = "2.8.2" -description = "Extensions to the standard Python datetime module" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -files = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, -] - -[package.dependencies] -six = ">=1.5" - -[[package]] -name = "pytz" -version = "2023.3" -description = "World timezone definitions, modern and historical" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"}, - {file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"}, -] - -[[package]] -name = "pytzdata" -version = "2020.1" -description = "The Olson timezone database for Python." -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "pytzdata-2020.1-py2.py3-none-any.whl", hash = "sha256:e1e14750bcf95016381e4d472bad004eef710f2d6417240904070b3d6654485f"}, - {file = "pytzdata-2020.1.tar.gz", hash = "sha256:3efa13b335a00a8de1d345ae41ec78dd11c9f8807f522d39850f2dd828681540"}, -] - -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -category = "main" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - -[[package]] -name = "tzlocal" -version = "1.5.1" -description = "tzinfo object for the local timezone" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "tzlocal-1.5.1.tar.gz", hash = "sha256:4ebeb848845ac898da6519b9b31879cf13b6626f7184c496037b818e238f2c4e"}, -] - -[package.dependencies] -pytz = "*" - [metadata] lock-version = "2.0" python-versions = "*" diff --git a/tests/fixtures/missing_directory_dependency/pyproject.toml b/tests/fixtures/missing_directory_dependency/pyproject.toml index 15ea51277cd..570ca5debc3 100644 --- a/tests/fixtures/missing_directory_dependency/pyproject.toml +++ b/tests/fixtures/missing_directory_dependency/pyproject.toml @@ -8,4 +8,6 @@ packages = [] [tool.poetry.dependencies] python = "*" + +[tool.poetry.dev-dependencies] missing = { path = "./missing" } diff --git a/tests/fixtures/missing_file_dependency/poetry.lock b/tests/fixtures/missing_file_dependency/poetry.lock new file mode 100644 index 00000000000..8230a5a9845 --- /dev/null +++ b/tests/fixtures/missing_file_dependency/poetry.lock @@ -0,0 +1,19 @@ +# This file is automatically @generated by Poetry and should not be changed by hand. + +[[package]] +name = "missing" +version = "1.2.3" +description = "" +optional = false +python-versions = "*" +files = [] +develop = false + +[package.source] +type = "file" +url = "missing-0.1.0-py2.py3-none-any.whl" + +[metadata] +lock-version = "2.0" +python-versions = "*" +content-hash = "bec78476925e4cda6b22e91551ce4337264bdc3394c4f8297ad238f67a436d0e" diff --git a/tests/fixtures/missing_file_dependency/pyproject.toml b/tests/fixtures/missing_file_dependency/pyproject.toml new file mode 100644 index 00000000000..0be727e2104 --- /dev/null +++ b/tests/fixtures/missing_file_dependency/pyproject.toml @@ -0,0 +1,13 @@ +[tool.poetry] +name = "project-with-missing-directory-dependency" +version = "1.2.3" +description = "This is a description" +authors = ["Your Name "] +license = "MIT" +packages = [] + +[tool.poetry.dependencies] +python = "*" + +[tool.poetry.dev-dependencies] +missing = { file = "missing-0.1.0-py2.py3-none-any.whl" } diff --git a/tests/fixtures/up_to_date_lock/poetry.lock b/tests/fixtures/up_to_date_lock/poetry.lock index 4155300cea5..8b2ca8737e0 100644 --- a/tests/fixtures/up_to_date_lock/poetry.lock +++ b/tests/fixtures/up_to_date_lock/poetry.lock @@ -1,15 +1,17 @@ -# This file is automatically @generated by Poetry 1.5.0.dev0 and should not be changed by hand. - [[package]] name = "certifi" version = "2020.12.5" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = "*" -files = [ - {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"}, - {file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"}, -] + +[[package.files]] +file = "certifi-2020.12.5-py2.py3-none-any.whl" +hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" + +[[package.files]] +file = "certifi-2020.12.5.tar.gz" +hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c" [[package]] name = "chardet" @@ -17,10 +19,14 @@ version = "4.0.0" description = "Universal encoding detector for Python 2 and 3" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"}, - {file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"}, -] + +[[package.files]] +file = "chardet-4.0.0-py2.py3-none-any.whl" +hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" + +[[package.files]] +file = "chardet-4.0.0.tar.gz" +hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa" [[package]] name = "docker" @@ -28,10 +34,14 @@ version = "4.3.1" description = "A Python library for the Docker Engine API." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "docker-4.3.1-py2.py3-none-any.whl", hash = "sha256:13966471e8bc23b36bfb3a6fb4ab75043a5ef1dac86516274777576bed3b9828"}, - {file = "docker-4.3.1.tar.gz", hash = "sha256:bad94b8dd001a8a4af19ce4becc17f41b09f228173ffe6a4e0355389eef142f2"}, -] + +[[package.files]] +file = "docker-4.3.1-py2.py3-none-any.whl" +hash = "sha256:13966471e8bc23b36bfb3a6fb4ab75043a5ef1dac86516274777576bed3b9828" + +[[package.files]] +file = "docker-4.3.1.tar.gz" +hash = "sha256:bad94b8dd001a8a4af19ce4becc17f41b09f228173ffe6a4e0355389eef142f2" [package.dependencies] pywin32 = {version = "227", markers = "sys_platform == \"win32\""} @@ -41,7 +51,7 @@ websocket-client = ">=0.32.0" [package.extras] ssh = ["paramiko (>=2.4.2)"] -tls = ["cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=17.5.0)"] +tls = ["pyOpenSSL (>=17.5.0)", "cryptography (>=1.3.4)", "idna (>=2.0.0)"] [[package]] name = "idna" @@ -49,10 +59,14 @@ version = "2.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, - {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, -] + +[[package.files]] +file = "idna-2.10-py2.py3-none-any.whl" +hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" + +[[package.files]] +file = "idna-2.10.tar.gz" +hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6" [[package]] name = "pywin32" @@ -60,20 +74,54 @@ version = "227" description = "Python for Window Extensions" optional = false python-versions = "*" -files = [ - {file = "pywin32-227-cp27-cp27m-win32.whl", hash = "sha256:371fcc39416d736401f0274dd64c2302728c9e034808e37381b5e1b22be4a6b0"}, - {file = "pywin32-227-cp27-cp27m-win_amd64.whl", hash = "sha256:4cdad3e84191194ea6d0dd1b1b9bdda574ff563177d2adf2b4efec2a244fa116"}, - {file = "pywin32-227-cp35-cp35m-win32.whl", hash = "sha256:f4c5be1a293bae0076d93c88f37ee8da68136744588bc5e2be2f299a34ceb7aa"}, - {file = "pywin32-227-cp35-cp35m-win_amd64.whl", hash = "sha256:a929a4af626e530383a579431b70e512e736e9588106715215bf685a3ea508d4"}, - {file = "pywin32-227-cp36-cp36m-win32.whl", hash = "sha256:300a2db938e98c3e7e2093e4491439e62287d0d493fe07cce110db070b54c0be"}, - {file = "pywin32-227-cp36-cp36m-win_amd64.whl", hash = "sha256:9b31e009564fb95db160f154e2aa195ed66bcc4c058ed72850d047141b36f3a2"}, - {file = "pywin32-227-cp37-cp37m-win32.whl", hash = "sha256:47a3c7551376a865dd8d095a98deba954a98f326c6fe3c72d8726ca6e6b15507"}, - {file = "pywin32-227-cp37-cp37m-win_amd64.whl", hash = "sha256:31f88a89139cb2adc40f8f0e65ee56a8c585f629974f9e07622ba80199057511"}, - {file = "pywin32-227-cp38-cp38-win32.whl", hash = "sha256:7f18199fbf29ca99dff10e1f09451582ae9e372a892ff03a28528a24d55875bc"}, - {file = "pywin32-227-cp38-cp38-win_amd64.whl", hash = "sha256:7c1ae32c489dc012930787f06244426f8356e129184a02c25aef163917ce158e"}, - {file = "pywin32-227-cp39-cp39-win32.whl", hash = "sha256:c054c52ba46e7eb6b7d7dfae4dbd987a1bb48ee86debe3f245a2884ece46e295"}, - {file = "pywin32-227-cp39-cp39-win_amd64.whl", hash = "sha256:f27cec5e7f588c3d1051651830ecc00294f90728d19c3bf6916e6dba93ea357c"}, -] + +[[package.files]] +file = "pywin32-227-cp27-cp27m-win32.whl" +hash = "sha256:371fcc39416d736401f0274dd64c2302728c9e034808e37381b5e1b22be4a6b0" + +[[package.files]] +file = "pywin32-227-cp27-cp27m-win_amd64.whl" +hash = "sha256:4cdad3e84191194ea6d0dd1b1b9bdda574ff563177d2adf2b4efec2a244fa116" + +[[package.files]] +file = "pywin32-227-cp35-cp35m-win32.whl" +hash = "sha256:f4c5be1a293bae0076d93c88f37ee8da68136744588bc5e2be2f299a34ceb7aa" + +[[package.files]] +file = "pywin32-227-cp35-cp35m-win_amd64.whl" +hash = "sha256:a929a4af626e530383a579431b70e512e736e9588106715215bf685a3ea508d4" + +[[package.files]] +file = "pywin32-227-cp36-cp36m-win32.whl" +hash = "sha256:300a2db938e98c3e7e2093e4491439e62287d0d493fe07cce110db070b54c0be" + +[[package.files]] +file = "pywin32-227-cp36-cp36m-win_amd64.whl" +hash = "sha256:9b31e009564fb95db160f154e2aa195ed66bcc4c058ed72850d047141b36f3a2" + +[[package.files]] +file = "pywin32-227-cp37-cp37m-win32.whl" +hash = "sha256:47a3c7551376a865dd8d095a98deba954a98f326c6fe3c72d8726ca6e6b15507" + +[[package.files]] +file = "pywin32-227-cp37-cp37m-win_amd64.whl" +hash = "sha256:31f88a89139cb2adc40f8f0e65ee56a8c585f629974f9e07622ba80199057511" + +[[package.files]] +file = "pywin32-227-cp38-cp38-win32.whl" +hash = "sha256:7f18199fbf29ca99dff10e1f09451582ae9e372a892ff03a28528a24d55875bc" + +[[package.files]] +file = "pywin32-227-cp38-cp38-win_amd64.whl" +hash = "sha256:7c1ae32c489dc012930787f06244426f8356e129184a02c25aef163917ce158e" + +[[package.files]] +file = "pywin32-227-cp39-cp39-win32.whl" +hash = "sha256:c054c52ba46e7eb6b7d7dfae4dbd987a1bb48ee86debe3f245a2884ece46e295" + +[[package.files]] +file = "pywin32-227-cp39-cp39-win_amd64.whl" +hash = "sha256:f27cec5e7f588c3d1051651830ecc00294f90728d19c3bf6916e6dba93ea357c" [[package]] name = "requests" @@ -81,10 +129,14 @@ version = "2.25.1" description = "Python HTTP for Humans." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "requests-2.25.1-py2.py3-none-any.whl", hash = "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"}, - {file = "requests-2.25.1.tar.gz", hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"}, -] + +[[package.files]] +file = "requests-2.25.1-py2.py3-none-any.whl" +hash = "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" + +[[package.files]] +file = "requests-2.25.1.tar.gz" +hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804" [package.dependencies] certifi = ">=2017.4.17" @@ -93,7 +145,7 @@ idna = ">=2.5,<3" urllib3 = ">=1.21.1,<1.27" [package.extras] -security = ["cryptography (>=1.3.4)", "pyOpenSSL (>=0.14)"] +security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] [[package]] @@ -102,10 +154,14 @@ version = "1.15.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, - {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, -] + +[[package.files]] +file = "six-1.15.0-py2.py3-none-any.whl" +hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" + +[[package.files]] +file = "six-1.15.0.tar.gz" +hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259" [[package]] name = "urllib3" @@ -113,14 +169,18 @@ version = "1.26.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" -files = [ - {file = "urllib3-1.26.3-py2.py3-none-any.whl", hash = "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80"}, - {file = "urllib3-1.26.3.tar.gz", hash = "sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73"}, -] + +[[package.files]] +file = "urllib3-1.26.3-py2.py3-none-any.whl" +hash = "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80" + +[[package.files]] +file = "urllib3-1.26.3.tar.gz" +hash = "sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73" [package.extras] brotli = ["brotlipy (>=0.6.0)"] -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"] +secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [[package]] @@ -129,10 +189,14 @@ version = "0.58.0" description = "WebSocket client for Python with low level API options" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "websocket_client-0.58.0-py2.py3-none-any.whl", hash = "sha256:44b5df8f08c74c3d82d28100fdc81f4536809ce98a17f0757557813275fbb663"}, - {file = "websocket_client-0.58.0.tar.gz", hash = "sha256:63509b41d158ae5b7f67eb4ad20fecbb4eee99434e73e140354dc3ff8e09716f"}, -] + +[[package.files]] +file = "websocket_client-0.58.0-py2.py3-none-any.whl" +hash = "sha256:44b5df8f08c74c3d82d28100fdc81f4536809ce98a17f0757557813275fbb663" + +[[package.files]] +file = "websocket_client-0.58.0.tar.gz" +hash = "sha256:63509b41d158ae5b7f67eb4ad20fecbb4eee99434e73e140354dc3ff8e09716f" [package.dependencies] six = "*" @@ -140,4 +204,4 @@ six = "*" [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "67c4543fd4f299cfeeaf82c5846ce720aa576e49811fbf9ccd0463ac8d5b52e4" +content-hash = "0cd068218f235c162f7b74bc8faf4ce3387b82daee1c1bb7a97af034f27ee116" diff --git a/tests/fixtures/up_to_date_lock/pyproject.toml b/tests/fixtures/up_to_date_lock/pyproject.toml index dd388ab9d00..555147605ea 100644 --- a/tests/fixtures/up_to_date_lock/pyproject.toml +++ b/tests/fixtures/up_to_date_lock/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Poetry Developer "] [tool.poetry.dependencies] python = "^3.8" -docker = ">=4.3.1" +docker = "4.3.1" [tool.poetry.dev-dependencies] diff --git a/tests/helpers.py b/tests/helpers.py index eefe9c74c1a..236745101c8 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -187,8 +187,12 @@ class TestLocker(Locker): __test__ = False def __init__(self, lock: Path, local_config: dict[str, Any]) -> None: - super().__init__(lock, local_config) + self._lock = lock + self._local_config = local_config + self._lock_data = None + self._content_hash = self._get_content_hash() self._locked = False + self._lock_data = None self._write = False def write(self, write: bool = True) -> None: diff --git a/tests/installation/test_installer.py b/tests/installation/test_installer.py index 6ef575b6fb8..01a16088fbc 100644 --- a/tests/installation/test_installer.py +++ b/tests/installation/test_installer.py @@ -1313,59 +1313,6 @@ def test_run_installs_with_local_poetry_directory_and_skip_directory_flag( assert installer.executor.installations_count == 6 -@pytest.mark.parametrize("skip_directory", [True, False]) -@pytest.mark.parametrize("locked", [True, False]) -def test_run_installs_with_skip_directory_flag_target_does_not_exist( - installer: Installer, - locker: Locker, - repo: Repository, - package: ProjectPackage, - fixture_dir: FixtureDirGetter, - skip_directory: bool, - locked: bool, -) -> None: - """When we set Installer.skip_directory(True) no path dependencies should - be installed (including transitive dependencies) and installation should succeed - even when a directory dependency is missing as long as the lockfile is present. - """ - root_dir = fixture_dir("") - package.root_dir = root_dir - directory = root_dir.joinpath("missing_directory_dependency") - locker.set_lock_path(directory) - locker.locked(locked) - dep_name = "project-with-missing-directory-dependency" - package.add_dependency( - Factory.create_dependency( - dep_name, - {"path": str(directory.relative_to(root_dir))}, - root_dir=root_dir, - ), - ) - - repo.add_package(get_package("pendulum", "1.4.4")) - - installer.skip_directory(skip_directory) - - if skip_directory and locked: - result = installer.run() - assert result == 0 - - assert isinstance(installer.executor, Executor) - directory_installs = [ - p.name - for p in installer.executor.installations - if p.source_type == "directory" - ] - assert not directory_installs, directory_installs - assert installer.executor.installations_count == 6 - else: - with pytest.raises( - ValueError, - match=r"Path .*missing for missing does not exist", - ): - installer.run() - - def test_run_installs_with_local_poetry_file_transitive( installer: Installer, locker: Locker, diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py index 363bb397607..546e5e44727 100644 --- a/tests/masonry/builders/test_editable_builder.py +++ b/tests/masonry/builders/test_editable_builder.py @@ -95,7 +95,7 @@ def test_builder_installs_proper_files_for_standard_packages( pth_file = Path("simple_project.pth") assert tmp_venv.site_packages.exists(pth_file) assert ( - simple_poetry.file.path.parent.resolve().as_posix() + simple_poetry.file.parent.resolve().as_posix() == tmp_venv.site_packages.find(pth_file)[0].read_text().strip(os.linesep) ) @@ -281,7 +281,7 @@ def test_builder_installs_proper_files_when_packages_configured( if line: paths.add(line) - project_root = project_with_include.file.path.parent.resolve() + project_root = project_with_include.file.parent.resolve() expected = {project_root.as_posix(), project_root.joinpath("src").as_posix()} assert paths.issubset(expected) @@ -339,5 +339,5 @@ def test_builder_should_execute_build_scripts( builder.build() assert [ - ["python", str(extended_without_setup_poetry.file.path.parent / "build.py")] + ["python", str(extended_without_setup_poetry.file.parent / "build.py")] ] == env.executed diff --git a/tests/pyproject/test_pyproject_toml_file.py b/tests/pyproject/test_pyproject_toml_file.py index 5cb1b8c4327..1c7c02a1439 100644 --- a/tests/pyproject/test_pyproject_toml_file.py +++ b/tests/pyproject/test_pyproject_toml_file.py @@ -25,5 +25,4 @@ def test_pyproject_toml_file_invalid(pyproject_toml: Path) -> None: def test_pyproject_toml_file_getattr(tmp_path: Path, pyproject_toml: Path) -> None: file = TOMLFile(pyproject_toml) - with pytest.warns(DeprecationWarning): - assert file.parent == tmp_path + assert file.parent == tmp_path diff --git a/tests/utils/conftest.py b/tests/utils/conftest.py index e9ec0be1ccf..8ad174758c4 100644 --- a/tests/utils/conftest.py +++ b/tests/utils/conftest.py @@ -17,5 +17,5 @@ def venv_name( ) -> str: return manager.generate_env_name( poetry.package.name, - str(poetry.file.path.parent), + str(poetry.file.parent), ) diff --git a/tests/utils/test_authenticator.py b/tests/utils/test_authenticator.py index 335e2b50c1e..2a0d1bee564 100644 --- a/tests/utils/test_authenticator.py +++ b/tests/utils/test_authenticator.py @@ -627,22 +627,6 @@ def test_authenticator_git_repositories( assert not three.password -def test_authenticator_get_cached_file_for_url__cache_miss(config: Config) -> None: - authenticator = Authenticator(config, NullIO()) - assert ( - authenticator.get_cached_file_for_url("https://foo.bar/cache/miss.whl") is None - ) - - -def test_authenticator_get_cached_file_for_url__cache_hit(config: Config) -> None: - authenticator = Authenticator(config, NullIO()) - url = "https://foo.bar/files/foo-0.1.0.tar.gz" - - authenticator._cache_control.set(url, b"hello") - - assert authenticator.get_cached_file_for_url(url) - - @pytest.mark.parametrize( ("ca_cert", "client_cert", "result"), [ diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py index f66f57482f8..6c5a17c4535 100644 --- a/tests/utils/test_env.py +++ b/tests/utils/test_env.py @@ -157,7 +157,7 @@ def test_env_get_supported_tags_matches_inside_virtualenv( @pytest.fixture def in_project_venv_dir(poetry: Poetry) -> Iterator[Path]: os.environ.pop("VIRTUAL_ENV", None) - venv_dir = poetry.file.path.parent.joinpath(".venv") + venv_dir = poetry.file.parent.joinpath(".venv") venv_dir.mkdir() try: yield venv_dir @@ -192,7 +192,6 @@ def check_output_wrapper( ) -> Callable[[list[str], Any, Any], str]: def check_output(cmd: list[str], *args: Any, **kwargs: Any) -> str: # cmd is a list, like ["python", "-c", "do stuff"] - assert all(isinstance(arg, str) for arg in cmd) python_cmd = cmd[2] if "sys.version_info[:3]" in python_cmd: return version.text @@ -843,7 +842,7 @@ def test_raises_if_acting_on_different_project_by_name( different_venv_name = ( EnvManager.generate_env_name( "different-project", - str(poetry.file.path.parent), + str(poetry.file.parent), ) + "-py3.6" ) @@ -1345,9 +1344,7 @@ def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable( version = Version.from_parts(*sys.version_info[:3]) assert version.minor is not None poetry.package.python_versions = f"~{version.major}.{version.minor - 1}.0" - venv_name = manager.generate_env_name( - "simple-project", str(poetry.file.path.parent) - ) + venv_name = manager.generate_env_name("simple-project", str(poetry.file.parent)) check_output = mocker.patch( "subprocess.check_output", @@ -1436,7 +1433,7 @@ def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir( manager.activate("python3.7") m.assert_called_with( - poetry.file.path.parent / ".venv", + poetry.file.parent / ".venv", executable=Path("/usr/bin/python3.7"), flags={ "always-copy": False, @@ -1775,7 +1772,7 @@ def test_create_venv_project_name_empty_sets_correct_prompt( manager = EnvManager(poetry) poetry.package.python_versions = "^3.7" - venv_name = manager.generate_env_name("", str(poetry.file.path.parent)) + venv_name = manager.generate_env_name("", str(poetry.file.parent)) mocker.patch("sys.version_info", (2, 7, 16)) mocker.patch("shutil.which", side_effect=lambda py: f"/usr/bin/{py}") diff --git a/tests/utils/test_password_manager.py b/tests/utils/test_password_manager.py index f2cbb7b7bce..d09f88b1fdf 100644 --- a/tests/utils/test_password_manager.py +++ b/tests/utils/test_password_manager.py @@ -3,7 +3,6 @@ import os from typing import TYPE_CHECKING -from unittest.mock import MagicMock import pytest @@ -223,7 +222,7 @@ def test_fail_keyring_should_be_unavailable( def test_get_http_auth_from_environment_variables( - environ: None, config: Config + environ: None, config: Config, with_simple_keyring: None ) -> None: os.environ["POETRY_HTTP_BASIC_FOO_USERNAME"] = "bar" os.environ["POETRY_HTTP_BASIC_FOO_PASSWORD"] = "baz" @@ -231,39 +230,10 @@ def test_get_http_auth_from_environment_variables( manager = PasswordManager(config) auth = manager.get_http_auth("foo") - assert auth == {"username": "bar", "password": "baz"} - - -def test_get_http_auth_does_not_call_keyring_when_credentials_in_environment_variables( - environ: None, config: Config -) -> None: - os.environ["POETRY_HTTP_BASIC_FOO_USERNAME"] = "bar" - os.environ["POETRY_HTTP_BASIC_FOO_PASSWORD"] = "baz" - - manager = PasswordManager(config) - manager._keyring = MagicMock() - - auth = manager.get_http_auth("foo") - assert auth == {"username": "bar", "password": "baz"} - manager._keyring.get_password.assert_not_called() - - -def test_get_http_auth_does_not_call_keyring_when_password_in_environment_variables( - environ: None, config: Config -) -> None: - config.merge( - { - "http-basic": {"foo": {"username": "bar"}}, - } - ) - os.environ["POETRY_HTTP_BASIC_FOO_PASSWORD"] = "baz" - - manager = PasswordManager(config) - manager._keyring = MagicMock() + assert auth is not None - auth = manager.get_http_auth("foo") - assert auth == {"username": "bar", "password": "baz"} - manager._keyring.get_password.assert_not_called() + assert auth["username"] == "bar" + assert auth["password"] == "baz" def test_get_pypi_token_with_env_var_positive(