Fix relative paths in tests

This commit is contained in:
Tzu-ping Chung
2018-04-12 17:48:04 +08:00
parent cde60ca58c
commit f730dd4899
2 changed files with 15 additions and 13 deletions
+8 -1
View File
@@ -30,6 +30,8 @@ def check_internet():
WE_HAVE_INTERNET = check_internet()
TESTS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def pytest_runtest_setup(item):
if item.get_marker('needs_internet') is not None and not WE_HAVE_INTERNET:
@@ -40,7 +42,7 @@ def pytest_sessionstart(session):
os.environ['PIPENV_DONT_USE_PYENV'] = '1'
os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1'
os.environ['PIPENV_VENV_IN_PROJECT'] = '1'
os.environ['PYPI_VENDOR_DIR'] = os.path.join(os.path.dirname(__file__), 'pypi')
os.environ['PYPI_VENDOR_DIR'] = os.path.join(TESTS_ROOT, 'pypi')
class _PipenvInstance(object):
@@ -136,3 +138,8 @@ def pip_src_dir(request):
request.addfinalizer(finalize)
return request
@pytest.fixture()
def testsroot():
return TESTS_ROOT
+7 -12
View File
@@ -6,9 +6,7 @@ try:
except ImportError:
import pathlib2 as pathlib
from pipenv.utils import mkdir_p
from pipenv.utils import temp_environ
from pipenv.utils import mkdir_p, temp_environ
import pytest
@@ -152,14 +150,13 @@ Requests = "==2.14.0" # Inline comment
@pytest.mark.resolver
@pytest.mark.eggs
@flaky
def test_local_package(PipenvInstance, pip_src_dir, pypi):
def test_local_package(PipenvInstance, pip_src_dir, pypi, testsroot):
"""This test ensures that local packages (directories with a setup.py)
installed in editable mode have their dependencies resolved as well"""
file_name = 'tablib-0.12.1.tar.gz'
package = 'tablib-0.12.1'
# Not sure where travis/appveyor run tests from
test_dir = os.path.dirname(os.path.abspath(__file__))
source_path = os.path.abspath(os.path.join(test_dir, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
with PipenvInstance(chdir=True, pypi=pypi) as p:
# This tests for a bug when installing a zipfile in the current dir
copy_to = os.path.join(p.path, file_name)
@@ -174,11 +171,10 @@ def test_local_package(PipenvInstance, pip_src_dir, pypi):
@pytest.mark.files
@flaky
def test_local_zipfiles(PipenvInstance, pypi):
def test_local_zipfiles(PipenvInstance, pypi, testsroot):
file_name = 'tablib-0.12.1.tar.gz'
# Not sure where travis/appveyor run tests from
test_dir = os.path.dirname(os.path.abspath(__file__))
source_path = os.path.abspath(os.path.join(test_dir, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
with PipenvInstance(chdir=True, pypi=pypi) as p:
# This tests for a bug when installing a zipfile in the current dir
@@ -200,10 +196,9 @@ def test_local_zipfiles(PipenvInstance, pypi):
@pytest.mark.files
@flaky
def test_relative_paths(PipenvInstance, pypi):
def test_relative_paths(PipenvInstance, pypi, testsroot):
file_name = 'tablib-0.12.1.tar.gz'
test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)))
source_path = os.path.abspath(os.path.join(test_dir, 'test_artifacts', file_name))
source_path = os.path.abspath(os.path.join(testsroot, 'test_artifacts', file_name))
with PipenvInstance(pypi=pypi) as p:
artifact_dir = 'artifacts'