def it_gives_the_same_python_version_as_we_started_with(tmpdir): other_python = OtherPython() with tmpdir.as_cwd(): requirements('') # first simulate some unrelated use of venv-update # this guards against statefulness in the venv-update scratch dir venv_update('venv=', 'unrelated_venv', 'pip-command=', 'true') run('virtualenv', '--python', other_python.interpreter, 'venv') initial_version = assert_python_version(other_python.version_prefix) venv_update_symlink_pwd() out, err = run('./venv/bin/python', 'venv_update.py') err = strip_pip_warnings(err) assert err == '' out = uncolor(out) assert out.startswith('''\ > virtualenv venv Keeping valid virtualenv from previous run. > rm -rf venv/local > pip install venv-update=={} '''.format(__version__)) final_version = assert_python_version(other_python.version_prefix) assert final_version == initial_version
def test_update_invalidated_while_active(tmpdir): tmpdir.chdir() enable_coverage() requirements('') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project-with-c') venv_update_symlink_pwd() out, err = run( 'sh', '-c', '. venv/bin/activate && python venv_update.py venv= --system-site-packages venv' ) err = strip_pip_warnings(err) assert err == '' out = uncolor(out) assert out.startswith('''\ > virtualenv --system-site-packages venv Removing invalidated virtualenv. (system-site-packages changed, to True) ''') assert 'project-with-c' in pip_freeze()
def it_gives_the_same_python_version_as_we_started_with(tmpdir): other_python = OtherPython() with tmpdir.as_cwd(): requirements('') # first simulate some unrelated use of venv-update # this guards against statefulness in the venv-update scratch dir venv_update('unrelated_venv', '--', '--version') run('virtualenv', '--python', other_python.interpreter, 'venv') initial_version = assert_python_version(other_python.version_prefix) venv_update_symlink_pwd() out, err = run('./venv/bin/python', 'venv_update.py') assert err == '' out = uncolor(out) assert out.startswith('''\ > virtualenv Keeping valid virtualenv from previous run. > venv/bin/python -m pip.__main__ install pip-faster==%s ''' % __version__) final_version = assert_python_version(other_python.version_prefix) assert final_version == initial_version
def test_update_while_active(tmpdir): tmpdir.chdir() enable_coverage() requirements('') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project_with_c') venv_update_symlink_pwd() out, err = run( 'sh', '-c', '. venv/bin/activate && python venv_update.py venv= venv --python=venv/bin/python' ) out = uncolor(out) err = strip_pip_warnings(err) assert err == '' assert out.startswith('''\ > virtualenv venv --python=venv/bin/python Keeping valid virtualenv from previous run. ''') assert 'project-with-c' in pip_freeze()
def test_recreate_active_virtualenv(tmpdir): with tmpdir.as_cwd(): run('virtualenv', 'venv') run('venv/bin/pip', 'install', '-r', str(TOP / 'requirements.d/coverage.txt')) requirements('project_with_c') venv_update_symlink_pwd() run('venv/bin/python', 'venv_update.py') assert_c_extension_runs()
def test_update_while_active(tmpdir, capfd): tmpdir.chdir() get_scenario('trivial') venv_update() assert 'mccabe' not in pip_freeze(capfd) with open('requirements.txt', 'w') as requirements: # An arbitrary small package: mccabe requirements.write('mccabe') venv_update_symlink_pwd() run('sh', '-c', '. virtualenv_run/bin/activate && python venv_update.py') assert 'mccabe' in pip_freeze(capfd)
def test_update_invalidated_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'mccabe' not in pip_freeze() # An arbitrary small package: mccabe requirements('virtualenv<2\nmccabe') venv_update_symlink_pwd() out, err = run('sh', '-c', '. virtualenv_run/bin/activate && python venv_update.py --system-site-packages') assert err == '' assert out.startswith('Removing invalidated virtualenv.\n') assert 'mccabe' in pip_freeze()
def test_update_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'mccabe' not in pip_freeze() # An arbitrary small package: mccabe requirements('virtualenv<2\nmccabe') venv_update_symlink_pwd() out, err = run('sh', '-c', '. virtualenv_run/bin/activate && python venv_update.py') assert err == '' assert out.startswith('Keeping virtualenv from previous run.\n') assert 'mccabe' in pip_freeze()
def test_update_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project_with_c') venv_update_symlink_pwd() out, err = run('sh', '-c', '. venv/bin/activate && python venv_update.py') out = uncolor(out) assert err == '' assert out.startswith('> virtualenv\nKeeping valid virtualenv from previous run.\n') assert 'project-with-c' in pip_freeze()
def test_update_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project_with_c') venv_update_symlink_pwd() out, err = run('sh', '-c', '. venv/bin/activate && python venv_update.py') out = uncolor(out) assert err == '' assert out.startswith( '> virtualenv\nKeeping valid virtualenv from previous run.\n') assert 'project-with-c' in pip_freeze()
def test_update_invalidated_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'mccabe' not in pip_freeze() # An arbitrary small package: mccabe requirements('virtualenv<2\nmccabe') venv_update_symlink_pwd() out, err = run( 'sh', '-c', '. virtualenv_run/bin/activate && python venv_update.py --system-site-packages' ) assert err == '' assert out.startswith('Removing invalidated virtualenv.\n') assert 'mccabe' in pip_freeze()
def test_update_invalidated_while_active(tmpdir): tmpdir.chdir() requirements('virtualenv<2') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project-with-c') venv_update_symlink_pwd() out, err = run('sh', '-c', '. venv/bin/activate && python venv_update.py --system-site-packages') err = strip_pip_warnings(err) assert err == '' out = uncolor(out) assert out.startswith('''\ > virtualenv --system-site-packages Removing invalidated virtualenv. ''') assert 'project-with-c' in pip_freeze()
def test_update_while_active(tmpdir): tmpdir.chdir() enable_coverage() requirements('') venv_update() assert 'project-with-c' not in pip_freeze() # An arbitrary small package: project_with_c requirements('project_with_c') venv_update_symlink_pwd() out, err = run('sh', '-c', '. venv/bin/activate && python venv_update.py venv= venv --python=venv/bin/python') out = uncolor(out) err = strip_pip_warnings(err) assert err == '' assert out.startswith('''\ > virtualenv venv --python=venv/bin/python Keeping valid virtualenv from previous run. ''') assert 'project-with-c' in pip_freeze()