mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #2612 from AltSchool/more-vcs-tests
Adding some git+git and git+ssh tests as examples
This commit is contained in:
@@ -28,7 +28,30 @@ def check_internet():
|
||||
return True
|
||||
|
||||
|
||||
def check_github_ssh():
|
||||
res = False
|
||||
try:
|
||||
# `ssh -T git@github.com` will return successfully with return_code==1
|
||||
# and message 'Hi <username>! You've successfully authenticated, but
|
||||
# GitHub does not provide shell access.' if ssh keys are available and
|
||||
# registered with GitHub. Otherwise, the command will fail with
|
||||
# return_code=255 and say 'Permission denied (publickey).'
|
||||
c = delegator.run('ssh -T git@github.com')
|
||||
res = True if c.return_code == 1 else False
|
||||
except Exception:
|
||||
pass
|
||||
if not res:
|
||||
warnings.warn(
|
||||
'Cannot connect to GitHub via SSH', ResourceWarning
|
||||
)
|
||||
warnings.warn(
|
||||
'Will skip tests requiring SSH access to GitHub', ResourceWarning
|
||||
)
|
||||
return res
|
||||
|
||||
|
||||
WE_HAVE_INTERNET = check_internet()
|
||||
WE_HAVE_GITHUB_SSH_KEYS = check_github_ssh()
|
||||
|
||||
TESTS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PYPI_VENDOR_DIR = os.path.join(TESTS_ROOT, 'pypi')
|
||||
@@ -38,6 +61,8 @@ prepare_pypi_packages(PYPI_VENDOR_DIR)
|
||||
def pytest_runtest_setup(item):
|
||||
if item.get_marker('needs_internet') is not None and not WE_HAVE_INTERNET:
|
||||
pytest.skip('requires internet')
|
||||
if item.get_marker('needs_github_ssh') is not None and not WE_HAVE_GITHUB_SSH_KEYS:
|
||||
pytest.skip('requires github ssh')
|
||||
|
||||
|
||||
class _PipenvInstance(object):
|
||||
|
||||
@@ -25,6 +25,39 @@ def test_basic_vcs_install(PipenvInstance, pip_src_dir, pypi):
|
||||
assert "gitdb2" in p.lockfile["default"]
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@pytest.mark.install
|
||||
@pytest.mark.needs_internet
|
||||
@flaky
|
||||
def test_git_vcs_install(PipenvInstance, pip_src_dir, pypi):
|
||||
with PipenvInstance(pypi=pypi, chdir=True) as p:
|
||||
c = p.pipenv("install git+git://github.com/benjaminp/six.git@1.11.0#egg=six")
|
||||
assert c.return_code == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
"git": "git://github.com/benjaminp/six.git",
|
||||
"ref": "15e31431af97e5e64b80af0a3f598d382bcdd49a",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.vcs
|
||||
@pytest.mark.install
|
||||
@pytest.mark.needs_github_ssh
|
||||
@pytest.mark.needs_internet
|
||||
@flaky
|
||||
def test_ssh_vcs_install(PipenvInstance, pip_src_dir, pypi):
|
||||
with PipenvInstance(pypi=pypi, chdir=True) as p:
|
||||
c = p.pipenv("install git+ssh://git@github.com/benjaminp/six.git@1.11.0#egg=six")
|
||||
assert c.return_code == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "git" in p.pipfile["packages"]["six"]
|
||||
assert p.lockfile["default"]["six"] == {
|
||||
"git": "ssh://git@github.com/benjaminp/six.git",
|
||||
"ref": "15e31431af97e5e64b80af0a3f598d382bcdd49a",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.files
|
||||
@pytest.mark.urls
|
||||
@pytest.mark.needs_internet
|
||||
|
||||
Reference in New Issue
Block a user