Skip to content

Instantly share code, notes, and snippets.

@sobolevn
Created February 2, 2018 19:25
Show Gist options
  • Save sobolevn/e9f72d535c1eae52ab441c0c940a0f2e to your computer and use it in GitHub Desktop.
Save sobolevn/e9f72d535c1eae52ab441c0c940a0f2e to your computer and use it in GitHub Desktop.
(pipenv-tests) ~/Desktop/pipenv master ✗
» pipenv run pytest -n 8 tests
Loading .env environment variables…
============================= test session starts ==============================
platform darwin -- Python 3.6.4, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /Users/sobolev/Desktop/pipenv, inifile:
plugins: xdist-1.22.0, forked-0.2
gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 ok / gw5 ok / gw6 ok / gw7 ogw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 ok / gw6 ok / gwgw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 ok /gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 [111] / gw7 [111]
scheduling tests via LoadScheduling
FFFFFF..s........s..s......F..................F......................... [ 64%]
...s....sss..ssssss.................... [100%]
=================================== FAILURES ===================================
_________ TestPipenv.test_pip_install_should_try_every_possible_source _________
[gw0] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x10d819518>
mocked_delegator = <MagicMock name='run' id='4521563808'>
mocked_sources = <PropertyMock name='sources' id='4521609312'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_install_should_try_every_possible_source(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://dontexistis.in.pypi/simple'},
{'url': 'http://existis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 1
second_cmd_return = Mock()
second_cmd_return.return_code = 0
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_install('package')
tests/test_legacy.py:28:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1397: in pip_install
quoted_pip = which_pip(allow_global=allow_global)
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4521610992'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
__ TestPipenv.test_pip_install_should_return_the_last_error_if_no_cmd_worked ___
[gw1] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x10858f470>
mocked_delegator = <MagicMock name='run' id='4435015160'>
mocked_sources = <PropertyMock name='sources' id='4435060664'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_install_should_return_the_last_error_if_no_cmd_worked(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://dontexistis.in.pypi/simple'},
{'url': 'http://dontexistis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 1
second_cmd_return = Mock()
second_cmd_return.return_code = 1
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_install('package')
tests/test_legacy.py:44:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1397: in pip_install
quoted_pip = which_pip(allow_global=allow_global)
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4435060384'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
_____ TestPipenv.test_pip_install_should_return_the_first_cmd_that_worked ______
[gw2] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x1091a2438>
mocked_delegator = <MagicMock name='run' id='4447675840'>
mocked_sources = <PropertyMock name='sources' id='4447725440'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_install_should_return_the_first_cmd_that_worked(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://existis.in.pypi/simple'},
{'url': 'http://existis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 0
second_cmd_return = Mock()
second_cmd_return.return_code = 0
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_install('package')
tests/test_legacy.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1397: in pip_install
quoted_pip = which_pip(allow_global=allow_global)
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4447727120'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
________ TestPipenv.test_pip_download_should_try_every_possible_source _________
[gw3] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x10cf29400>
mocked_delegator = <MagicMock name='run' id='4512191880'>
mocked_sources = <PropertyMock name='sources' id='4512253768'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_download_should_try_every_possible_source(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://dontexistis.in.pypi/simple'},
{'url': 'http://existis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 1
second_cmd_return = Mock()
second_cmd_return.return_code = 0
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_download('package')
tests/test_legacy.py:78:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1424: in pip_download
which_pip(),
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4512254104'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
_____ TestPipenv.test_pip_download_should_return_the_first_cmd_that_worked _____
[gw5] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x10af3a400>
mocked_delegator = <MagicMock name='run' id='4478707080'>
mocked_sources = <PropertyMock name='sources' id='4478760776'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_download_should_return_the_first_cmd_that_worked(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://existis.in.pypi/simple'},
{'url': 'http://existis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 0
second_cmd_return = Mock()
second_cmd_return.return_code = 0
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_download('package')
tests/test_legacy.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1424: in pip_download
which_pip(),
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4478761112'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
__ TestPipenv.test_pip_download_should_return_the_last_error_if_no_cmd_worked __
[gw4] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_legacy.TestPipenv object at 0x10ce83438>
mocked_delegator = <MagicMock name='run' id='4511512000'>
mocked_sources = <PropertyMock name='sources' id='4511565640'>
@patch('pipenv.project.Project.sources', new_callable=PropertyMock)
@patch('delegator.run')
def test_pip_download_should_return_the_last_error_if_no_cmd_worked(self, mocked_delegator, mocked_sources):
sources = [
{'url': 'http://dontexistis.in.pypi/simple'},
{'url': 'http://dontexistis.in.pypi/simple'}
]
mocked_sources.return_value = sources
first_cmd_return = Mock()
first_cmd_return.return_code = 1
second_cmd_return = Mock()
second_cmd_return.return_code = 1
mocked_delegator.side_effect = [first_cmd_return, second_cmd_return]
> c = pip_download('package')
tests/test_legacy.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pipenv/cli.py:1424: in pip_download
which_pip(),
pipenv/cli.py:1462: in which_pip
return which('pip')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
command = 'pip', location = <Mock name='mock.out.strip()' id='4511565920'>
allow_global = False
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
> p = os.sep.join([location] + ['bin/{0}'.format(command)])
E TypeError: sequence item 0: expected str instance, Mock found
pipenv/cli.py:1443: TypeError
________________ TestPipenv.test_activate_virtualenv_no_source _________________
[gw3] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_pipenv.TestPipenv object at 0x10d47b550>
@pytest.mark.code
@pytest.mark.virtualenv
def test_activate_virtualenv_no_source(self):
command = activate_virtualenv(source=False)
venv = Project().virtualenv_location
> assert command == '{0}/bin/activate'.format(venv)
E assert "<Mock name='.../bin/activate" == '/Users/sobole.../bin/activate'
E - <Mock name='mock.out.strip().replace()' id='4517771752'>/bin/activate
E + /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/activate
tests/test_pipenv.py:812: AssertionError
_________________ TestPipenv.test_shell_nested_venv_in_project _________________
[gw1] darwin -- Python 3.6.4 /Users/sobolev/.virtualenvs/pipenv-vENc4TPO/bin/python3.6
self = <tests.test_pipenv.TestPipenv object at 0x108ae1080>
@pytest.mark.dotvenv
@pytest.mark.install
@pytest.mark.complex
@pytest.mark.shell
@pytest.mark.windows
@pytest.mark.pew
def test_shell_nested_venv_in_project(self):
import subprocess
with temp_environ():
os.environ['PIPENV_VENV_IN_PROJECT'] = '1'
os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1'
os.environ['PIPENV_SHELL_COMPAT'] = '1'
with PipenvInstance(chdir=True) as p:
# Signal to pew to look in the project directory for the environment
os.environ['WORKON_HOME'] = p.path
project = Project()
c = p.pipenv('install requests')
assert c.return_code == 0
assert 'requests' in p.pipfile['packages']
assert 'requests' in p.lockfile['default']
# Check that .venv now shows in pew's managed list
pew_list = delegator.run('pew ls')
assert '.venv' in pew_list.out
# Check for the venv directory
c = delegator.run('pew dir .venv')
# Compare pew's virtualenv path to what we expect
venv_path = get_windows_path(project.project_directory, '.venv')
# os.path.normpath will normalize slashes
> assert venv_path == normalize_drive(os.path.normpath(c.out.strip()))
E AssertionError: assert '/private/var...project/.venv' == '/var/folders/...project/.venv'
E - /private/var/folders/qn/2gssw9hx48g81chw0398hlrr0000gn/T/pipenvucqdw68pproject/.venv
E ? --------
E + /var/folders/qn/2gssw9hx48g81chw0398hlrr0000gn/T/pipenvucqdw68pproject/.venv
tests/test_pipenv.py:685: AssertionError
----------------------------- Captured stdout call -----------------------------
$ pipenv install requests
Installing requests…
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2018.1.18-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: certifi, idna, urllib3, chardet, requests
Successfully installed certifi-2018.1.18 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22
Adding requests to Pipfile's [packages]…
PS: You have excellent taste! ✨ 🍰 ✨
Creating a virtualenv for this project…
Using real prefix '/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6'
New python executable in /var/folders/qn/2gssw9hx48g81chw0398hlrr0000gn/T/pipenvucqdw68pproject/.venv/bin/python3.6
Also creating executable in /var/folders/qn/2gssw9hx48g81chw0398hlrr0000gn/T/pipenvucqdw68pproject/.venv/bin/python
Installing setuptools, pip, wheel...done.
Virtualenv location: /var/folders/qn/2gssw9hx48g81chw0398hlrr0000gn/T/pipenvucqdw68pproject/.venv
Creating a Pipfile for this project…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (2f8679)!
============== 8 failed, 90 passed, 13 skipped in 359.01 seconds ===============
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment