Skip to content

[WIP] Add a very basic test suite #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
virtualenv
scripttest
51 changes: 51 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os
import sys
import scripttest

# Locate get-pip.py relative to this test file
GET_PIP = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'get-pip.py')

# Handle platform specific differences
if sys.platform.startswith('win'):
BIN_DIR = 'Scripts'
def exe_base(path):
"""Command name of an executable"""
return os.path.splitext(os.path.basename(path))[0]
else:
BIN_DIR = 'bin'
def exe_base(path):
"""Command name of an executable"""
return os.path.basename(path)


def test_install(tmpdir):
"""Simple test that installing pip using get-pip works"""

# Create a scripttest environment
env = scripttest.TestFileEnvironment(tmpdir / 'env')

# Create a virtual environment with no pip present.
# TODO: add the following cases
# 1. environment name with spaces
# 2. environment with some version of pip already present

ve_name = 've'
env.run('virtualenv', '--no-pip', '--no-setuptools', '--no-wheel',
ve_name)
ve_python = os.path.join(ve_name, BIN_DIR, 'python')

# Run get-pip.py from this repository
result = env.run(ve_python, GET_PIP)

# Check if the pip command was created
created_pip = None
for name, file_obj in result.files_created.items():
if exe_base(name) == 'pip' and file_obj.file:
created_pip = file_obj
break
assert created_pip

# Confirm that both the pip exe and python -m pip work
env.run(created_pip.full, '--version')
env.run(ve_python, '-m', 'pip', '--version')