summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2017-07-14 08:58:14 +0200
committerBenoit Pierre <benoit.pierre@gmail.com>2017-07-15 06:36:32 +0200
commit95386da92ec1725a09c5cd8e457be5ff3dc15a3e (patch)
treebe7b47bba743e03b42603ba6a98ea889a5985063
parentbf20d881df662da30d94687efb2ff3d3ba32f55a (diff)
downloadpython-setuptools-git-95386da92ec1725a09c5cd8e457be5ff3dc15a3e.tar.gz
tests: rework clean install test
Use pytest-virtualenv so the test can be run no Windows too.
-rw-r--r--.travis.yml3
-rw-r--r--setuptools/tests/test_virtualenv.py31
-rwxr-xr-xtests/clean_install.sh27
-rw-r--r--tests/requirements.txt3
4 files changed, 34 insertions, 30 deletions
diff --git a/.travis.yml b/.travis.yml
index cbf49da6..b207a8d2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -43,7 +43,4 @@ install:
# update egg_info based on setup.py in checkout
- python bootstrap.py
-# Check that setuptools can be installed in a clean environment
-- tests/clean_install.sh
-
script: tox
diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py
new file mode 100644
index 00000000..eb8db7a6
--- /dev/null
+++ b/setuptools/tests/test_virtualenv.py
@@ -0,0 +1,31 @@
+import os
+
+from pytest import yield_fixture
+from pytest_fixture_config import yield_requires_config
+
+import pytest_virtualenv
+
+
+@yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable'])
+@yield_fixture(scope='function')
+def bare_virtualenv():
+ """ Bare virtualenv (no pip/setuptools/wheel).
+ """
+ with pytest_virtualenv.VirtualEnv(args=(
+ '--no-wheel',
+ '--no-pip',
+ '--no-setuptools',
+ )) as venv:
+ yield venv
+
+
+SOURCE_DIR = os.path.join(os.path.dirname(__file__), '../..')
+
+def test_clean_env_install(bare_virtualenv):
+ """
+ Check setuptools can be installed in a clean environment.
+ """
+ bare_virtualenv.run(' && '.join((
+ 'cd {source}',
+ 'python setup.py install',
+ )).format(source=SOURCE_DIR))
diff --git a/tests/clean_install.sh b/tests/clean_install.sh
deleted file mode 100755
index f8f80dc7..00000000
--- a/tests/clean_install.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env bash
-
-# This test was created in
-# https://github.com/pypa/setuptools/pull/1050
-# but it really should be incorporated into the test suite
-# such that it runs on Windows and doesn't depend on
-# virtualenv. Moving to test_integration will likely address
-# those concerns.
-
-set -o errexit
-set -o xtrace
-
-# Create a temporary directory to install the virtualenv in
-VENV_DIR="$(mktemp -d)"
-function cleanup() {
- rm -rf "$VENV_DIR"
-}
-trap cleanup EXIT
-
-# Create a virtualenv that doesn't have pip or setuptools installed
-wget https://raw.githubusercontent.com/pypa/virtualenv/master/virtualenv.py
-python virtualenv.py --no-wheel --no-pip --no-setuptools "$VENV_DIR"
-source "$VENV_DIR/bin/activate"
-
-# Now try to install setuptools
-python bootstrap.py
-python setup.py install
diff --git a/tests/requirements.txt b/tests/requirements.txt
index ddba6cc8..0c4df8ef 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,3 +1,6 @@
+importlib; python_version<"2.7"
mock
pytest-flake8
+pytest-virtualenv>=1.2.7
pytest>=3.0.2
+virtualenv