mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
9848862927
* Check point progress on moving tests to pypiserver. * Allow other indexes to mimic the pypi json API for package hashes. * Fix these tests that run on lower python versions only. * Try adding the pypiserver to the github actions to only run once. * Expand the scope of fixtures for pypiserver. * try to accomedate microsoft runner. * Windows networking troubles. * Remove running as a background job. * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to condtionally invoke different start pypi-server commands * Try to introduce pypi as the root index because setuptools-scm is not in our pypi artifacts. * see if the windows tests run faster (and the other tests) by supplying waitress. * Only use waitress on windows because the others are fast on the default. Fix requests pollution. * Supply a suitable Pipfile instead for these two failing tests. * More requests resolver cross test contamination cleanup. * remove problematic tests because even on my version of python 3.8.12 this does not work due to AttributeError: 'HTMLParser' object has no attribute 'unescape' * fix mirror install test. * Fix Pipfile. * Fix Pipfile for real * Fix tests * Cleanup test naming and more test enhancements. * Save this optimization for a subsequent PR. * Cleanup the TemporaryDirectory between tests. * resolve merge conflict. * Cleanup path initalization -- it hsould always be a TemporaryDirectory for tests that gets cleanedup. * Cleanup path initalization -- it hsould always be a TemporaryDirectory for tests that gets cleanedup. * tableflip on those requests tests that read the setup metadata in reqlib from other tests. * Update developer documentation for running tests. * add news fragment. * Try gunicorn perfoormance for linux/mac * Only use gunicorn on linux based on the results of last run.
181 lines
5.7 KiB
Python
181 lines
5.7 KiB
Python
import os
|
|
|
|
import pytest
|
|
|
|
from flaky import flaky
|
|
|
|
from pipenv.patched import pipfile
|
|
from pipenv.project import Project
|
|
from pipenv.utils.shell import temp_environ
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.markers
|
|
def test_package_environment_markers(pipenv_instance_pypi):
|
|
|
|
with pipenv_instance_pypi() as p:
|
|
with open(p.pipfile_path, 'w') as f:
|
|
contents = """
|
|
[packages]
|
|
fake_package = {version = "*", markers="os_name=='splashwear'"}
|
|
""".strip()
|
|
f.write(contents)
|
|
|
|
c = p.pipenv('install')
|
|
assert c.returncode == 0
|
|
assert 'markers' in p.lockfile['default']['fake-package'], p.lockfile["default"]
|
|
|
|
c = p.pipenv('run python -c "import fake_package;"')
|
|
assert c.returncode == 1
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.markers
|
|
def test_platform_python_implementation_marker(pipenv_instance_private_pypi):
|
|
"""Markers should be converted during locking to help users who input this
|
|
incorrectly.
|
|
"""
|
|
with pipenv_instance_private_pypi() as p:
|
|
c = p.pipenv('install depends-on-marked-package')
|
|
assert c.returncode == 0
|
|
|
|
# depends-on-marked-package has an install_requires of
|
|
# 'pytz; platform_python_implementation=="CPython"'
|
|
# Verify that that marker shows up in our lockfile unaltered.
|
|
assert 'pytz' in p.lockfile['default']
|
|
assert p.lockfile['default']['pytz'].get('markers') == \
|
|
"platform_python_implementation == 'CPython'"
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.alt
|
|
@pytest.mark.markers
|
|
@pytest.mark.install
|
|
def test_specific_package_environment_markers(pipenv_instance_pypi):
|
|
|
|
with pipenv_instance_pypi() as p:
|
|
with open(p.pipfile_path, 'w') as f:
|
|
contents = """
|
|
[packages]
|
|
six = {version = "*", os_name = "== 'splashwear'"}
|
|
""".strip()
|
|
f.write(contents)
|
|
|
|
c = p.pipenv('install')
|
|
assert c.returncode == 0
|
|
assert 'markers' in p.lockfile['default']['six']
|
|
|
|
c = p.pipenv('run python -c "import six;"')
|
|
assert c.returncode == 1
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.markers
|
|
def test_top_level_overrides_environment_markers(pipenv_instance_pypi):
|
|
"""Top-level environment markers should take precedence.
|
|
"""
|
|
with pipenv_instance_pypi() as p:
|
|
with open(p.pipfile_path, 'w') as f:
|
|
contents = """
|
|
[packages]
|
|
apscheduler = "*"
|
|
funcsigs = {version = "*", os_name = "== 'splashwear'"}
|
|
""".strip()
|
|
f.write(contents)
|
|
|
|
c = p.pipenv('install')
|
|
assert c.returncode == 0
|
|
assert "markers" in p.lockfile['default']['funcsigs'], p.lockfile['default']['funcsigs']
|
|
assert p.lockfile['default']['funcsigs']['markers'] == "os_name == 'splashwear'", p.lockfile['default']['funcsigs']
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.markers
|
|
@pytest.mark.install
|
|
def test_global_overrides_environment_markers(pipenv_instance_pypi):
|
|
"""Empty (unconditional) dependency should take precedence.
|
|
If a dependency is specified without environment markers, it should
|
|
override dependencies with environment markers. In this example,
|
|
APScheduler requires funcsigs only on Python 2, but since funcsigs is
|
|
also specified as an unconditional dep, its markers should be empty.
|
|
"""
|
|
with pipenv_instance_pypi() as p:
|
|
with open(p.pipfile_path, 'w') as f:
|
|
contents = """
|
|
[packages]
|
|
apscheduler = "*"
|
|
funcsigs = "*"
|
|
""".strip()
|
|
f.write(contents)
|
|
|
|
c = p.pipenv('install')
|
|
assert c.returncode == 0
|
|
|
|
assert p.lockfile['default']['funcsigs'].get('markers', '') == ''
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.markers
|
|
@pytest.mark.complex
|
|
def test_resolver_unique_markers(pipenv_instance_pypi):
|
|
"""vcrpy has a dependency on `yarl` which comes with a marker
|
|
of 'python version in "3.4, 3.5, 3.6" - this marker duplicates itself:
|
|
|
|
'yarl; python version in "3.4, 3.5, 3.6"; python version in "3.4, 3.5, 3.6"'
|
|
|
|
This verifies that we clean that successfully.
|
|
"""
|
|
with pipenv_instance_pypi(chdir=True) as p:
|
|
c = p.pipenv('install vcrpy==2.0.1')
|
|
assert c.returncode == 0
|
|
assert 'yarl' in p.lockfile['default']
|
|
yarl = p.lockfile['default']['yarl']
|
|
assert 'markers' in yarl
|
|
# Two possible marker sets are ok here
|
|
assert yarl['markers'] in [
|
|
"python_version in '3.4, 3.5, 3.6'",
|
|
"python_version >= '3.4'",
|
|
"python_version >= '3.5'", # yarl 1.3.0 requires python 3.5.3
|
|
]
|
|
|
|
|
|
@flaky
|
|
@pytest.mark.project
|
|
@pytest.mark.needs_internet
|
|
def test_environment_variable_value_does_not_change_hash(pipenv_instance_private_pypi):
|
|
with pipenv_instance_private_pypi(chdir=True) as p:
|
|
with temp_environ():
|
|
with open(p.pipfile_path, 'w') as f:
|
|
f.write("""
|
|
[[source]]
|
|
url = 'https://${PYPI_USERNAME}:${PYPI_PASSWORD}@pypi.org/simple'
|
|
verify_ssl = true
|
|
name = 'pypi'
|
|
|
|
[packages]
|
|
six = "*"
|
|
""")
|
|
project = Project()
|
|
|
|
os.environ['PYPI_USERNAME'] = 'whatever'
|
|
os.environ['PYPI_PASSWORD'] = 'pass'
|
|
assert project.get_lockfile_hash() is None
|
|
|
|
c = p.pipenv('install')
|
|
assert c.returncode == 0
|
|
lock_hash = project.get_lockfile_hash()
|
|
assert lock_hash is not None
|
|
assert lock_hash == project.calculate_pipfile_hash()
|
|
|
|
# sanity check on pytest
|
|
assert 'PYPI_USERNAME' not in str(pipfile.load(p.pipfile_path))
|
|
assert c.returncode == 0
|
|
assert project.get_lockfile_hash() == project.calculate_pipfile_hash()
|
|
|
|
os.environ['PYPI_PASSWORD'] = 'pass2'
|
|
assert project.get_lockfile_hash() == project.calculate_pipfile_hash()
|
|
|
|
with open(p.pipfile_path, 'a') as f:
|
|
f.write('requests = "==2.14.0"\n')
|
|
assert project.get_lockfile_hash() != project.calculate_pipfile_hash()
|