예제 #1
0
    def test_environment_variable_value_does_not_change_hash(self, pypi):
        with PipenvInstance(chdir=True, pypi=pypi) as p:
            with temp_environ():
                with open(p.pipfile_path, 'w') as f:
                    f.write("""
[[source]]
url = 'https://${PYPI_USERNAME}:${PYPI_PASSWORD}@pypi.python.org/simple'
verify_ssl = true
name = 'pypi'

[requires]
python_version = '2.7'

[packages]
flask = "==0.12.2"
""")
                os.environ['PYPI_USERNAME'] = '******'
                os.environ['PYPI_PASSWORD'] = '******'
                assert Project().get_lockfile_hash() is None
                c = p.pipenv('install')
                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.return_code == 0
                assert Project().get_lockfile_hash() == Project(
                ).calculate_pipfile_hash()
                os.environ['PYPI_PASSWORD'] = '******'
                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()
예제 #2
0
def test_pipfile_envvar_expansion(PipenvInstance):
    with PipenvInstance(chdir=True) as p:
        with temp_environ():
            with open(p.pipfile_path, 'w') as f:
                f.write("""
[[source]]
url = 'https://${TEST_HOST}/simple'
verify_ssl = false
name = "pypi"

[packages]
pytz = "*"
                """.strip())
            os.environ['TEST_HOST'] = 'localhost:5000'
            project = Project()
            assert project.sources[0]['url'] == 'https://localhost:5000/simple'
            assert 'localhost:5000' not in str(pipfile.load(p.pipfile_path))
예제 #3
0
def test_pipfile_envvar_expansion(PipenvInstance):
    with PipenvInstance(chdir=True) as p:
        with temp_environ():
            with open(p.pipfile_path, 'w') as f:
                f.write("""
[[source]]
url = 'https://${TEST_HOST}/simple'
verify_ssl = false
name = "pypi"

[packages]
pytz = "*"
                """.strip())
            os.environ['TEST_HOST'] = 'localhost:5000'
            project = Project()
            assert project.sources[0]['url'] == 'https://localhost:5000/simple'
            assert 'localhost:5000' not in str(pipfile.load(p.pipfile_path))
예제 #4
0
def test_environment_variable_value_does_not_change_hash(PipenvInstance):
    with PipenvInstance(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'] = '******'
            os.environ['PYPI_PASSWORD'] = '******'
            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'] = '******'
            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()
예제 #5
0
def test_environment_variable_value_does_not_change_hash(PipenvInstance, pypi):
    with PipenvInstance(chdir=True, pypi=pypi) 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'
[requires]
python_version = '2.7'
[packages]
flask = "==0.12.2"
""")
            project = Project()

            os.environ['PYPI_USERNAME'] = '******'
            os.environ['PYPI_PASSWORD'] = '******'
            assert project.get_lockfile_hash() is None

            c = p.pipenv('install')
            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.return_code == 0
            assert project.get_lockfile_hash() == project.calculate_pipfile_hash()

            os.environ['PYPI_PASSWORD'] = '******'
            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()