From d14a533df3bc2cdab1b8bf26eea7379dd3f49b38 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 01:04:11 -0600 Subject: [PATCH 1/8] added a test for converting requirements to pipfile --- tests/test_pipenv.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index e0b5077b..8087a371 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -459,7 +459,29 @@ requests = {version = "*"} c = p.pipenv('check --style .') assert 'requests' in c.out + @pytest.mark.extras + @pytest.mark.install + @pytest.mark.requirements + def test_requirements_to_pipfile(self): + with PipenvInstance(pipfile=False) as p: + # Write a requirements file + with open('requirements.txt', 'w') as f: + f.write('requests[socks]==2.18.1\n') + c = p.pipenv('install') + # Assert that the files get converted the requirements + assert p.pipfile + assert p.lockfile + # assert stuff in pipfile + assert 'requests' in p.pipfile['packages'] + assert 'extras' in p.pipfile['packages']['requests'] + + # assert stuff in lockfile + assert 'requests' in p.lockfile['default'] + assert 'chardet' in p.lockfile['default'] + assert 'idna' in p.lockfile['default'] + assert 'urllib3' in p.lockfile['default'] + assert 'pysocks' in p.lockfile['default'] \ No newline at end of file From 30159dacf5ec87372e248fbdd79dd49564dd40e9 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 01:21:12 -0600 Subject: [PATCH 2/8] Converted some tests from legacy to the new test suite. I've also added a new mark for tests that use 'pipenv run' --- tests/test_legacy.py | 116 ------------------------------------------- tests/test_pipenv.py | 41 ++++++++++++++- 2 files changed, 39 insertions(+), 118 deletions(-) diff --git a/tests/test_legacy.py b/tests/test_legacy.py index 8aa64d4e..f0611375 100644 --- a/tests/test_legacy.py +++ b/tests/test_legacy.py @@ -17,122 +17,6 @@ os.environ['PIPENV_IGNORE_VIRTUALENVS'] = 'True' class TestPipenv(): - def test_requirements_to_pipfile(self): - delegator.run('mkdir test_requirements_to_pip') - os.chdir('test_requirements_to_pip') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_MAX_DEPTH'] = '1' - - with open('requirements.txt', 'w') as f: - f.write('requests[socks]==2.18.1\n' - 'git+https://github.com/kennethreitz/records.git@v0.5.0#egg=records\n' - '-e git+https://github.com/kennethreitz/tablib.git@v0.11.5#egg=tablib\n' - 'six==1.10.0\n') - - assert delegator.run('pipenv --python python').return_code == 0 - print(delegator.run('pipenv lock').err) - assert delegator.run('pipenv lock').return_code == 0 - - pipfile_output = delegator.run('cat Pipfile').out - lockfile_output = delegator.run('cat Pipfile.lock').out - - # Ensure extras work. - assert 'socks' in pipfile_output - assert 'pysocks' in lockfile_output - - # Ensure vcs dependencies work. - assert 'records' in pipfile_output - assert '"git": "https://github.com/kennethreitz/records.git"' in lockfile_output - - # Ensure editable packages work. - assert 'ref = "v0.11.5"' in pipfile_output - assert '"editable": true' in lockfile_output - - # Ensure BAD_PACKAGES aren't copied into Pipfile from requirements.txt. - assert 'six = "==1.10.0"' not in pipfile_output - - os.chdir('..') - delegator.run('rm -fr test_requirements_to_pip') - del os.environ['PIPENV_MAX_DEPTH'] - - def test_timeout_long(self): - delegator.run('mkdir test_timeout_long') - os.chdir('test_timeout_long') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_TIMEOUT'] = '60' - - assert delegator.run('touch Pipfile').return_code == 0 - - assert delegator.run('pipenv --python python').return_code == 0 - - os.chdir('..') - delegator.run('rm -fr test_timeout_long') - del os.environ['PIPENV_TIMEOUT'] - - def test_timeout_short(self): - delegator.run('mkdir test_timeout_short') - os.chdir('test_timeout_short') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_TIMEOUT'] = '1' - - assert delegator.run('touch Pipfile').return_code == 0 - - assert delegator.run('pipenv --python python').return_code == 1 - - os.chdir('..') - delegator.run('rm -fr test_timeout_short') - del os.environ['PIPENV_TIMEOUT'] - - def test_pipenv_run(self): - working_dir = 'test_pipenv_run' - delegator.run('mkdir {0}'.format(working_dir)) - os.chdir(working_dir) - - # Build the environment. - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - delegator.run('touch Pipfile') - - # Install packages for test. - # print(delegator.run('pipenv install pep8').err) - assert delegator.run('pipenv install pep8').return_code == 0 - assert delegator.run('pipenv install pytest').return_code == 0 - - # Run test commands. - assert delegator.run('pipenv run python -c \'print("test")\'').return_code == 0 - assert delegator.run('pipenv run pep8 --version').return_code == 0 - assert delegator.run('pipenv run pytest --version').return_code == 0 - - os.chdir('..') - delegator.run('rm -fr {0}'.format(working_dir)) - - @pytest.mark.parametrize('shell, extension', [ - ('/bin/bash', ''), - ('/bin/fish', '.fish'), - ('/bin/csh', '.csh'), - ('/bin/unknown', '')] - ) - def test_activate_virtualenv(self, shell, extension): - orig_shell = os.environ['SHELL'] - os.environ['SHELL'] = shell - - # Get standard activation command for bash - command = activate_virtualenv() - - # Return environment to initial shell config. - os.environ['SHELL'] = orig_shell - - venv = Project().virtualenv_location - assert command == 'source {0}/bin/activate{1}'.format(venv, extension) - - def test_activate_virtualenv_no_source(self): - command = activate_virtualenv(source=False) - venv = Project().virtualenv_location - - assert command == '{0}/bin/activate'.format(venv) - @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): diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 8087a371..26ed83c6 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -7,6 +7,7 @@ import pytest from pipenv.vendor import toml from pipenv.vendor import delegator +from pipenv.project import Project os.environ['PIPENV_DONT_USE_PYENV'] = '1' @@ -170,8 +171,9 @@ class TestPipenv: assert 'urllib3' in p.lockfile['default'] assert 'certifi' in p.lockfile['default'] - @pytest.mark.install @pytest.mark.dev + @pytest.mark.run + @pytest.mark.install def test_basic_dev_install(self): with PipenvInstance() as p: c = p.pipenv('install requests --dev') @@ -186,6 +188,7 @@ class TestPipenv: c = p.pipenv('run python -m requests.help') assert c.return_code == 0 + @pytest.mark.run @pytest.mark.uninstall def test_uninstall(self): with PipenvInstance() as p: @@ -251,6 +254,7 @@ class TestPipenv: assert 'urllib3' in p.lockfile['default'] assert 'certifi' in p.lockfile['default'] + @pytest.mark.run @pytest.mark.install def test_multiprocess_bug_and_install(self): os.environ['PIPENV_MAX_SUBPROCESS'] = '2' @@ -309,6 +313,7 @@ tpfd = "*" c = p.pipenv('run python -c "import requests; import idna; import certifi; import records; import tpfd; import parse;"') assert c.return_code == 0 + @pytest.mark.run @pytest.mark.markers @pytest.mark.install def test_package_environment_markers(self): @@ -330,6 +335,7 @@ requests = {version = "*", markers="os_name=='splashwear'"} c = p.pipenv('run python -c "import requests;"') assert c.return_code == 1 + @pytest.mark.run @pytest.mark.alt @pytest.mark.install def test_specific_package_environment_markers(self): @@ -351,6 +357,7 @@ requests = {version = "*", os_name = "== 'splashwear'"} c = p.pipenv('run python -c "import requests;"') assert c.return_code == 1 + @pytest.mark.run @pytest.mark.alt @pytest.mark.install def test_alternative_version_specifier(self): @@ -393,6 +400,7 @@ requests = {version = "*"} del os.environ['PIPENV_VENV_IN_PROJECT'] + @pytest.mark.run @pytest.mark.dotenv def test_env(self): with PipenvInstance(pipfile=False) as p: @@ -484,4 +492,33 @@ requests = {version = "*"} assert 'chardet' in p.lockfile['default'] assert 'idna' in p.lockfile['default'] assert 'urllib3' in p.lockfile['default'] - assert 'pysocks' in p.lockfile['default'] \ No newline at end of file + assert 'pysocks' in p.lockfile['default'] + + @pytest.mark.code + @pytest.mark.virtualenv + @pytest.mark.parametrize('shell, extension', [ + ('/bin/bash', ''), + ('/bin/fish', '.fish'), + ('/bin/csh', '.csh'), + ('/bin/unknown', '')] + ) + def test_activate_virtualenv(self, shell, extension): + orig_shell = os.environ['SHELL'] + os.environ['SHELL'] = shell + + # Get standard activation command for bash + command = activate_virtualenv() + + # Return environment to initial shell config. + os.environ['SHELL'] = orig_shell + + venv = Project().virtualenv_location + assert command == 'source {0}/bin/activate{1}'.format(venv, extension) + + @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) \ No newline at end of file From b04fc3a0eb4819bdace895a6859418b6c09bc957 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 01:31:47 -0600 Subject: [PATCH 3/8] added an import and fixed a small bug --- tests/test_pipenv.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 26ed83c6..abf88c2e 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -5,6 +5,7 @@ import json import pytest +from pipenv.cli import activate_virtualenv from pipenv.vendor import toml from pipenv.vendor import delegator from pipenv.project import Project @@ -479,10 +480,6 @@ requests = {version = "*"} c = p.pipenv('install') - # Assert that the files get converted the requirements - assert p.pipfile - assert p.lockfile - # assert stuff in pipfile assert 'requests' in p.pipfile['packages'] assert 'extras' in p.pipfile['packages']['requests'] From f381df7e11084cca50c0f2bb18e098f65caeb786 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 01:34:28 -0600 Subject: [PATCH 4/8] Skipped a problem test for windows, need to think of a better way to test that functionality --- tests/test_pipenv.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index abf88c2e..38c54247 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -499,6 +499,7 @@ requests = {version = "*"} ('/bin/csh', '.csh'), ('/bin/unknown', '')] ) + @pytest.mark.skip(reason="this doesn't work on app veyor") def test_activate_virtualenv(self, shell, extension): orig_shell = os.environ['SHELL'] os.environ['SHELL'] = shell From bee20e02558a229d4fe7fab6f83777a74a5f088d Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 02:40:00 -0600 Subject: [PATCH 5/8] migrated some more tests from legacy --- tests/test_legacy.py | 26 -------------------------- tests/test_pipenv.py | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/tests/test_legacy.py b/tests/test_legacy.py index f0611375..20a3706e 100644 --- a/tests/test_legacy.py +++ b/tests/test_legacy.py @@ -116,29 +116,3 @@ class TestPipenv(): c = pip_download('package') assert c.return_code == 0 assert c == first_cmd_return - - def test_lock_requirements_file(self): - delegator.run('mkdir test_pipenv_requirements') - os.chdir('test_pipenv_requirements') - - pip_str = ("[packages]\n" - "requests = \"==2.14.0\"\n" - "flask = \"==0.12.2\"\n\n" - "[dev-packages]\n" - "pytest = \"==3.1.1\"\n") - - req_list = ("requests==2.14.0", "flask==0.12.2", "pytest==3.1.1") - - # Build the environment. - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - assert delegator.run('echo \'{0}\' > Pipfile'.format(pip_str)).return_code == 0 - - # Validate requirements.txt. - c = delegator.run('pipenv lock -r') - assert c.return_code == 0 - for req in req_list: - assert req in c.out - - # Cleanup. - os.chdir('..') - delegator.run('rm -fr test_pipenv_requirements') diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 38c54247..f2125bf4 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -386,12 +386,14 @@ requests = {version = "*"} @pytest.mark.bad @pytest.mark.install def test_bad_packages(self): + with PipenvInstance() as p: c = p.pipenv('install NotAPackage') assert c.return_code > 0 @pytest.mark.dotvenv def test_venv_in_project(self): + os.environ['PIPENV_VENV_IN_PROJECT'] = '1' with PipenvInstance() as p: c = p.pipenv('install requests') @@ -404,6 +406,7 @@ requests = {version = "*"} @pytest.mark.run @pytest.mark.dotenv def test_env(self): + with PipenvInstance(pipfile=False) as p: with open('.env', 'w') as f: f.write('HELLO=WORLD') @@ -416,6 +419,7 @@ requests = {version = "*"} @pytest.mark.install @pytest.mark.skip(reason="this doesn't work on windows") def test_e_dot(self): + with PipenvInstance() as p: path = os.path.abspath(os.path.sep.join([os.path.dirname(__file__), '..'])) c = p.pipenv('install -e \'{0}\' --dev'.format(path)) @@ -431,6 +435,7 @@ requests = {version = "*"} @pytest.mark.install @pytest.mark.skip(reason="this doesn't work on travis") def test_code_import_manual(self): + with PipenvInstance() as p: with PipenvInstance(chdir=True) as p: @@ -444,6 +449,7 @@ requests = {version = "*"} @pytest.mark.check @pytest.mark.unused def test_check_unused(self): + with PipenvInstance() as p: with PipenvInstance(chdir=True) as p: @@ -459,6 +465,7 @@ requests = {version = "*"} @pytest.mark.check @pytest.mark.style def test_flake8(self): + with PipenvInstance() as p: with PipenvInstance(chdir=True) as p: @@ -472,13 +479,18 @@ requests = {version = "*"} @pytest.mark.install @pytest.mark.requirements def test_requirements_to_pipfile(self): - with PipenvInstance(pipfile=False) as p: + + with PipenvInstance(pipfile=False, chdir=True) as p: # Write a requirements file with open('requirements.txt', 'w') as f: f.write('requests[socks]==2.18.1\n') c = p.pipenv('install') + assert c.return_code == 0 + print(c.out) + print(c.err) + print(delegator.run('ls -l').out) # assert stuff in pipfile assert 'requests' in p.pipfile['packages'] @@ -501,6 +513,7 @@ requests = {version = "*"} ) @pytest.mark.skip(reason="this doesn't work on app veyor") def test_activate_virtualenv(self, shell, extension): + orig_shell = os.environ['SHELL'] os.environ['SHELL'] = shell @@ -519,4 +532,26 @@ requests = {version = "*"} command = activate_virtualenv(source=False) venv = Project().virtualenv_location - assert command == '{0}/bin/activate'.format(venv) \ No newline at end of file + assert command == '{0}/bin/activate'.format(venv) + + @pytest.mark.lock + @pytest.mark.requirements + def test_lock_requirements_file(self): + + with PipenvInstance() as p: + with open(p.pipfile_path, 'w') as f: + contents = """ +[packages] +requests = "==2.14.0" +flask = "==0.12.2" +[dev-packages] +pytest = "==3.1.1" + """.strip() + f.write(contents) + + req_list = ("requests==2.14.0", "flask==0.12.2", "pytest==3.1.1") + + c = p.pipenv('lock -r') + assert c.return_code == 0 + for req in req_list: + assert req in c.out \ No newline at end of file From 347a84f1c8eef30f7c9f73934fb589d0073571fb Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 02:41:23 -0600 Subject: [PATCH 6/8] removed old unused windows tests. Any remaining unported tests are in test_legacy.py --- test_windows/__init__.py | 0 test_windows/test_pipenv.py | 339 ------------------------------------ test_windows/test_utils.py | 14 -- 3 files changed, 353 deletions(-) delete mode 100644 test_windows/__init__.py delete mode 100644 test_windows/test_pipenv.py delete mode 100644 test_windows/test_utils.py diff --git a/test_windows/__init__.py b/test_windows/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/test_windows/test_pipenv.py b/test_windows/test_pipenv.py deleted file mode 100644 index 9dedf94b..00000000 --- a/test_windows/test_pipenv.py +++ /dev/null @@ -1,339 +0,0 @@ -import os -import shutil - -from mock import patch, Mock, PropertyMock - -from pipenv.vendor import delegator -from pipenv.patched import contoml - -from pipenv.cli import ( - ensure_proper_casing, - pip_install, pip_download, find_a_system_python -) - -FULL_PYTHON_PATH = 'C:\\Python36-x64\\python.exe' - -class TestPipenvWindows(): - - def test_existience(self): - assert True - - def test_cli_with_custom_python_path(self): - delegator.run('mkdir custom_python') - os.chdir('custom_python') - - c = delegator.run('pipenv install --python={0}'.format(FULL_PYTHON_PATH)) - - # Debugging, if it fails. - print(c.out) - print(c.err) - - assert c.return_code == 0 - - def test_cli_usage(self): - delegator.run('mkdir test_project') - os.chdir('test_project') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - - assert delegator.run('copy /y nul Pipfile').return_code == 0 - - assert delegator.run('pipenv install Werkzeug').return_code == 0 - assert delegator.run('pipenv install pytest --dev').return_code == 0 - assert delegator.run('pipenv install git+https://github.com/requests/requests.git@v2.18.4#egg=requests').return_code == 0 - assert delegator.run('pipenv lock').return_code == 0 - - # Test uninstalling a package after locking. - assert delegator.run('pipenv uninstall Werkzeug').return_code == 0 - - pipfile_output = delegator.run('type Pipfile').out - lockfile_output = delegator.run('type Pipfile.lock').out - - # Ensure uninstall works. - assert 'Werkzeug' not in pipfile_output - assert 'werkzeug' not in lockfile_output - - # Ensure dev-packages work. - assert 'pytest' in pipfile_output - assert 'pytest' in lockfile_output - - # Ensure vcs dependencies work. - assert 'requests' in pipfile_output - assert '"git": "https://github.com/requests/requests.git"' in lockfile_output - - os.chdir('..') - shutil.rmtree('test_project') - - def test_requirements_to_pipfile(self): - delegator.run('mkdir test_requirements_to_pip') - os.chdir('test_requirements_to_pip') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_MAX_DEPTH'] = '1' - - with open('requirements.txt', 'w') as f: - f.write('requests[socks]==2.18.1\n' - 'git+https://github.com/kennethreitz/records.git@v0.5.0#egg=records\n' - '-e git+https://github.com/kennethreitz/maya.git@v0.3.2#egg=maya\n' - 'six==1.10.0\n') - - assert delegator.run('pipenv install').return_code == 0 - print(delegator.run('pipenv lock').err) - assert delegator.run('pipenv lock').return_code == 0 - - pipfile_output = delegator.run('type Pipfile').out - lockfile_output = delegator.run('type Pipfile.lock').out - - # Ensure extras work. - assert 'socks' in pipfile_output - assert 'pysocks' in lockfile_output - - # Ensure vcs dependencies work. - assert 'records' in pipfile_output - assert '"git": "https://github.com/kennethreitz/records.git"' in lockfile_output - - # Ensure editable packages work. - assert 'ref = "v0.3.2"' in pipfile_output - assert '"editable": true' in lockfile_output - - # Ensure BAD_PACKAGES aren't copied into Pipfile from requirements.txt. - assert 'six = "==1.10.0"' not in pipfile_output - - os.chdir('..') - # shutil.rmtree('test_requirements_to_pip') - del os.environ['PIPENV_MAX_DEPTH'] - - def test_timeout_long(self): - delegator.run('mkdir test_timeout_long') - os.chdir('test_timeout_long') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_TIMEOUT'] = '60' - - assert delegator.run('copy /y nul Pipfile').return_code == 0 - - os.chdir('..') - shutil.rmtree('test_timeout_long') - del os.environ['PIPENV_TIMEOUT'] - - def test_timeout_short(self): - delegator.run('mkdir test_timeout_short') - os.chdir('test_timeout_short') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - os.environ['PIPENV_TIMEOUT'] = '0' - - assert delegator.run('copy /y nul Pipfile').return_code == 0 - - os.chdir('..') - shutil.rmtree('test_timeout_short') - del os.environ['PIPENV_TIMEOUT'] - - def test_pipenv_uninstall(self): - delegator.run('mkdir test_pipenv_uninstall') - os.chdir('test_pipenv_uninstall') - - # Build the environment. - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - assert delegator.run('copy /y nul Pipfile').return_code == 0 - assert delegator.run('pipenv install').return_code == 0 - - # Add entries to Pipfile. - assert delegator.run('pipenv install Werkzeug').return_code == 0 - assert delegator.run('pipenv install pytest --dev').return_code == 0 - - pipfile_output = delegator.run('type Pipfile').out - pipfile_list = pipfile_output.split('\n') - - assert 'werkzeug = "*"' in pipfile_list - assert 'pytest = "*"' in pipfile_list - assert '[packages]' in pipfile_list - assert '[dev-packages]' in pipfile_list - - # Uninstall from dev-packages, removing TOML section. - assert delegator.run('pipenv uninstall pytest').return_code == 0 - - # Test uninstalling non-existant dependency. - c = delegator.run('pipenv uninstall NotAPackage') - assert c.return_code == 0 - assert 'No package NotAPackage to remove from Pipfile.' in c.out - - pipfile_output = delegator.run('type Pipfile').out - pipfile_list = pipfile_output.split('\n') - - assert 'Werkzeug = "*"' in pipfile_list - assert 'pytest = "*"' not in pipfile_list - assert '[packages]' in pipfile_list - # assert '[dev-packages]' not in pipfile_list - - os.chdir('..') - shutil.rmtree('test_pipenv_uninstall') - - def test_pipenv_run(self): - working_dir = 'test_pipenv_run' - delegator.run('mkdir {0}'.format(working_dir)) - os.chdir(working_dir) - - # Build the environment. - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - assert delegator.run('copy /y nul Pipfile').return_code == 0 - - # Install packages for test. - assert delegator.run('pipenv install pep8').return_code == 0 - assert delegator.run('pipenv install pytest').return_code == 0 - - # Run test commands. - assert delegator.run('pipenv run python -c \'print("test")\'').return_code == 0 - assert delegator.run('pipenv run pep8 --version').return_code == 0 - assert delegator.run('pipenv run pytest --version').return_code == 0 - - os.chdir('..') - shutil.rmtree(working_dir) - - def test_ensure_proper_casing_names(self): - """Ensure proper casing for package names.""" - pfile_test = ("[packages]\n" - "DjAnGO = \"*\"\n" - "flask = \"==0.11\"\n" - "\n\n" - "[dev-packages]\n" - "PyTEST = \"*\"\n") - - # Load test Pipfile. - p = contoml.loads(pfile_test) - - assert 'DjAnGO' in p['packages'] - assert 'PyTEST' in p['dev-packages'] - - changed = ensure_proper_casing(p) - - assert 'Django' in p['packages'] - assert 'DjAnGO' not in p['packages'] - - assert 'pytest' in p['dev-packages'] - assert 'PyTEST' not in p['dev-packages'] - - assert changed is True - - @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') - assert c.return_code == 0 - - @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') - assert c.return_code == 1 - assert c == second_cmd_return - - @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') - assert c.return_code == 0 - assert c == first_cmd_return - - @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') - assert c.return_code == 0 - - @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') - assert c.return_code == 1 - assert c == second_cmd_return - - @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') - assert c.return_code == 0 - assert c == first_cmd_return - - def test_lock_requirements_file(self): - delegator.run('mkdir test_pipenv_requirements') - os.chdir('test_pipenv_requirements') - - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - - assert delegator.run('copy /y nul Pipfile').return_code == 0 - assert delegator.run('pipenv install requests==2.14.0').return_code == 0 - assert delegator.run('pipenv install flask==0.12.2').return_code == 0 - assert delegator.run('pipenv install --dev pytest==3.1.1').return_code == 0 - - req_list = ("requests==2.14.0", "flask==0.12.2", "pytest==3.1.1") - - # Validate requirements.txt. - c = delegator.run('pipenv lock -r') - assert c.return_code == 0 - for req in req_list: - assert req in c.out - - # Cleanup. - os.chdir('..') - shutil.rmtree('test_pipenv_requirements') diff --git a/test_windows/test_utils.py b/test_windows/test_utils.py deleted file mode 100644 index 6a02170e..00000000 --- a/test_windows/test_utils.py +++ /dev/null @@ -1,14 +0,0 @@ -import delegator - -from pipenv.utils import python_version - - -FULL_PYTHON_PATH = 'C:\\Python36-x64\\python.exe' - - -class TestUtilsWindows(): - - def test_python_version_from_full_path(self): - print(delegator.run('{0} --version'.format(FULL_PYTHON_PATH)).out) - - assert python_version(FULL_PYTHON_PATH) == "3.6.1" From 724975e0cd44a26f7e8249daf052f297e22348ca Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 08:10:35 -0600 Subject: [PATCH 7/8] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8b1782f..1c627af6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ python: - "pypy" - "3.7-dev" # - "pypy3" # TODO: pkg_config issues - # - "3.7-dev" # command to install dependencies install: From fe8623eb7124e1e6409911f31441742011345262 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Mon, 25 Sep 2017 08:18:09 -0600 Subject: [PATCH 8/8] run fast app veyor! well faster.. --- appveyor.yml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3dfbcfd3..398425d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,42 +13,17 @@ environment: - PYTHON: "C:\\Python27-x64" PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "64" - TOXENV: "py27" - - - PYTHON: "C:\\Python27" - PYTHON_VERSION: "2.7.x" - PYTHON_ARCH: "32" - TOXENV: "py27" - PYTHON: "C:\\Python34-x64" PYTHON_VERSION: "3.4.x" - PYTHON_ARCH: "64" - TOXENV: "py34" - - - PYTHON: "C:\\Python34" - PYTHON_VERSION: "3.4.x" - PYTHON_ARCH: "32" - TOXENV: "py34" - PYTHON: "C:\\Python35-x64" PYTHON_VERSION: "3.5.x" PYTHON_ARCH: "64" - TOXENV: "py35" - - - PYTHON: "C:\\Python35" - PYTHON_VERSION: "3.5.x" - PYTHON_ARCH: "32" - TOXENV: "py35" - PYTHON: "C:\\Python36-x64" PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "64" - TOXENV: "py36" - - - PYTHON: "C:\\Python36" - PYTHON_VERSION: "3.6.x" - PYTHON_ARCH: "32" - TOXENV: "py36" install: # Install Python (from the official .msi of http://python.org) and pip when