Skip python2-virtualenv tests

This commit is contained in:
Miro Hrončok 2019-07-25 18:06:41 +02:00
parent b5e9f71561
commit 36d098078c
2 changed files with 34 additions and 2 deletions

View File

@ -101,6 +101,10 @@ Patch3: remove-existing-dist-only-if-path-conflicts.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1655253
Patch4: dummy-certifi.patch
# When virtualenv is not available, skip the tests instead of failing
# Once we no longer ship or test python2-pip, remove this patch
Patch5: skip-virtualenv-tests.patch
# Downstream only patch
# Users might have local installations of pip from using
# `pip install --user --upgrade pip` on older versions.
@ -183,7 +187,6 @@ BuildRequires: python2-pytest
BuildRequires: python2-pretend
BuildRequires: python2-freezegun
BuildRequires: python2-scripttest
BuildRequires: python2-virtualenv
BuildRequires: python2-pyyaml
%endif
%if %{without bootstrap}
@ -297,6 +300,7 @@ popd
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
# this goes together with patch4
rm src/pip/_vendor/certifi/*.pem
@ -453,7 +457,8 @@ export PATH="$PWD/_bin:$PATH"
%if %{with python2}
export PYTHONPATH=%{buildroot}%{python2_sitelib}
ln -s %{buildroot}%{_bindir}/pip2 _bin/pip
%{__python2} -m pytest -m 'not network' -k "$(echo $pytest_k)"
# test_more_than_one_package assumes virtualenv is present
%{__python2} -m pytest -m 'not network' -k "$(echo $pytest_k) and not test_more_than_one_package"
%endif

View File

@ -0,0 +1,27 @@
diff --git a/tests/lib/venv.py b/tests/lib/venv.py
index 6b63391..126db5b 100644
--- a/tests/lib/venv.py
+++ b/tests/lib/venv.py
@@ -4,8 +4,12 @@ import compileall
import sys
import textwrap
+import pytest
import six
-import virtualenv as _virtualenv
+try:
+ import virtualenv as _virtualenv
+except ImportError:
+ _virtualenv = None
from .path import Path
@@ -20,6 +24,8 @@ class VirtualEnvironment(object):
"""
def __init__(self, location, template=None, venv_type=None):
+ if _virtualenv is None:
+ pytest.skip('virtualenv not available')
assert template is None or venv_type is None
assert venv_type in (None, 'virtualenv', 'venv')
self.location = Path(location)