Files
pipenv/tests/integration/test_sync.py
T
Matt Davis 7458b32e34 Bump requirements lib to v3.0.0 (#5679)
* Port over latest requirementslib sample changes to pydantic.

* fix import

* port over more changes from other attempt.

* port over more changes from other attempt.

* Iterate

* fix some tests

* fix markers tests

* Spot check changes back towards what was passing in pipenv prior.

* Parity with latest requirementslib changes

* latest changes that work for both pipenv and requirementslib.

* Hack for cross-test contamination looking for version of six that isn't in the private pypi.

* Differences between reqlib3 and prototype branch

* corrrect re-written imports that were wrong.
2023-06-26 23:54:47 +02:00

98 lines
2.6 KiB
Python

import json
import os
import pytest
from pipenv.utils.shell import temp_environ
@pytest.mark.lock
@pytest.mark.sync
def test_sync_error_without_lockfile(pipenv_instance_pypi):
with pipenv_instance_pypi(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
""".strip())
c = p.pipenv('sync')
assert c.returncode != 0
assert 'Pipfile.lock not found!' in c.stderr
@pytest.mark.sync
@pytest.mark.lock
def test_mirror_lock_sync(pipenv_instance_private_pypi):
with temp_environ(), pipenv_instance_private_pypi(chdir=True) as p:
mirror_url = os.environ.get('PIPENV_TEST_INDEX')
assert 'pypi.org' not in mirror_url
with open(p.pipfile_path, 'w') as f:
f.write("""
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[packages]
six = "==1.12.0"
""".strip())
c = p.pipenv(f'lock --pypi-mirror {mirror_url}')
assert c.returncode == 0
c = p.pipenv(f'sync --pypi-mirror {mirror_url}')
assert c.returncode == 0
@pytest.mark.sync
@pytest.mark.lock
def test_sync_should_not_lock(pipenv_instance_pypi):
"""Sync should not touch the lock file, even if Pipfile is changed.
"""
with pipenv_instance_pypi(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
""".strip())
# Perform initial lock.
c = p.pipenv('lock')
assert c.returncode == 0
lockfile_content = p.lockfile
assert lockfile_content
# Make sure sync does not trigger lockfile update.
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
six = "*"
""".strip())
c = p.pipenv('sync')
assert c.returncode == 0
assert lockfile_content == p.lockfile
@pytest.mark.sync
def test_sync_consider_pip_target(pipenv_instance_pypi):
"""
"""
with pipenv_instance_pypi(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write("""
[packages]
six = "*"
""".strip())
# Perform initial lock.
c = p.pipenv('lock')
assert c.returncode == 0
lockfile_content = p.lockfile
assert lockfile_content
c = p.pipenv('sync')
assert c.returncode == 0
pip_target_dir = 'target_dir'
os.environ['PIP_TARGET'] = pip_target_dir
c = p.pipenv('sync')
assert c.returncode == 0
assert 'six.py' in os.listdir(os.path.join(p.path, pip_target_dir))
os.environ.pop('PIP_TARGET')