How to use pipenv - 10 common examples

To help you get started, we’ve selected a few pipenv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / pipenv / tests / integration / test_install_basic.py View on Github external
def test_system_and_deploy_work(PipenvInstance, pypi):
    with PipenvInstance(chdir=True, pypi=pypi) as p:
        c = p.pipenv("install six requests")
        assert c.return_code == 0
        c = p.pipenv("--rm")
        assert c.return_code == 0
        c = delegator.run("virtualenv .venv")
        assert c.return_code == 0
        c = p.pipenv("install --system --deploy")
        assert c.return_code == 0
        c = p.pipenv("--rm")
        assert c.return_code == 0
        Path(p.pipfile_path).write_text(
            u"""
[packages]
requests
        """.strip()
        )
        c = p.pipenv("install --system")
        assert c.return_code == 0
github pypa / pipenv / test_windows / test_pipenv.py View on Github external
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']
github pypa / pipenv / test_windows / test_pipenv.py View on Github external
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')
github pypa / pipenv / test_windows / test_pipenv.py View on Github external
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
github pypa / pipenv / test_windows / test_pipenv.py View on Github external
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']
github pypa / pipenv / test_windows / test_pipenv.py View on Github external
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
github pypa / pipenv / tests / unit / test_utils.py View on Github external
def test_convert_deps_to_pip_unicode():
    deps = {u"django": u"==1.10"}
    deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
    assert deps[0] == "django==1.10"
github pypa / pipenv / tests / test_project.py View on Github external
def test_proper_names(self):
        proj = pipenv.project.Project()
        assert proj.virtualenv_location in proj.proper_names_location
        assert isinstance(proj.proper_names, list)
github pypa / pipenv / tests / test_project.py View on Github external
def test_parsed_pipfile(self):
        proj = pipenv.project.Project()

        # Create test space.
        delegator.run('mkdir test_pipfile')
        with open('test_pipfile/Pipfile', 'w') as f:
            f.write('[[source]]\nurl = \'https://pypi.python.org/simple\'\n'
                    'verify_ssl = true\n\n\n[packages]\n'
                    'requests = { extras = [\'socks\'] }')

        proj._pipfile_location = 'test_pipfile/Pipfile'
        pfile = proj.parsed_pipfile

        # Cleanup test space.
        delegator.run('rm -fr test_pipfile')

        # Confirm source added correctly.
        assert 'source' in pfile
github pypa / pipenv / tests / test_project.py View on Github external
def test_internal_pipfile(self):
        proj = pipenv.project.Project()

        # Create test space.
        delegator.run('mkdir test_internal_pipfile')
        with open('test_internal_pipfile/Pipfile', 'w') as f:
            f.write('[[source]]\nurl = \'https://pypi.python.org/simple\'\n'
                    'verify_ssl = true\n\n\n[packages]\n'
                    'Requests = { extras = [\'socks\'] }\nFlask_Auth = \'*\'\n\n\n'
                    '[dev-packages]\nclick = \'*\'\nDjango = {git = '
                    '"https://github.com/django/django.git", ref="1.10"}\n')

        proj._pipfile_location = 'test_internal_pipfile/Pipfile'

        p = proj._pipfile

        # Test package names are normalized as expected.
        assert list(p['packages'].keys()) == ['requests', 'flask-auth']