Project cannot be a fixture

This commit is contained in:
Tzu-ping Chung
2018-04-12 17:34:03 +08:00
parent 92cc570588
commit 1dea2a27b2
6 changed files with 19 additions and 14 deletions
-6
View File
@@ -4,7 +4,6 @@ import warnings
import pytest
from pipenv.project import Project
from pipenv.utils import TemporaryDirectory
from pipenv.vendor import delegator
from pipenv.vendor import requests
@@ -137,8 +136,3 @@ def pip_src_dir(request):
request.addfinalizer(finalize)
return request
@pytest.fixture()
def project():
return Project()
+3 -2
View File
@@ -1,5 +1,6 @@
import os
from pipenv.project import Project
from pipenv.utils import temp_environ, normalize_drive, get_windows_path
from pipenv.vendor import delegator
@@ -47,7 +48,7 @@ def test_reuse_previous_venv(PipenvInstance, pypi):
@pytest.mark.windows
@pytest.mark.pew
@pytest.mark.skip('Not mocking this.')
def test_shell_nested_venv_in_project(PipenvInstance, pypi, project):
def test_shell_nested_venv_in_project(PipenvInstance, pypi):
import subprocess
with temp_environ():
os.environ['PIPENV_VENV_IN_PROJECT'] = '1'
@@ -65,7 +66,7 @@ def test_shell_nested_venv_in_project(PipenvInstance, pypi, project):
# Check for the venv directory
c = delegator.run('pewtwo dir .venv')
# Compare pew's virtualenv path to what we expect
venv_path = get_windows_path(project.project_directory, '.venv')
venv_path = get_windows_path(Project().project_directory, '.venv')
# os.path.normpath will normalize slashes
assert venv_path == normalize_drive(os.path.normpath(c.out.strip()))
# Have pew run 'pip freeze' in the virtualenv
+4 -1
View File
@@ -1,6 +1,7 @@
import os
import sys
from pipenv.project import Project
from pipenv.utils import temp_environ
from pipenv.vendor import pipfile
@@ -125,7 +126,7 @@ def test_resolver_unique_markers(PipenvInstance, pypi):
@pytest.mark.project
@flaky
def test_environment_variable_value_does_not_change_hash(PipenvInstance, pypi, project):
def test_environment_variable_value_does_not_change_hash(PipenvInstance, pypi):
with PipenvInstance(chdir=True, pypi=pypi) as p:
with temp_environ():
with open(p.pipfile_path, 'w') as f:
@@ -139,6 +140,8 @@ python_version = '2.7'
[packages]
flask = "==0.12.2"
""")
project = Project()
os.environ['PYPI_USERNAME'] = 'whatever'
os.environ['PYPI_PASSWORD'] = 'pass'
assert project.get_lockfile_hash() is None
+3 -2
View File
@@ -4,6 +4,7 @@ XXX: Try our best to reduce tests in this file.
"""
from pipenv.core import activate_virtualenv
from pipenv.project import Project
import pytest
@@ -23,9 +24,9 @@ def test_code_import_manual(PipenvInstance):
@pytest.mark.code
@pytest.mark.virtualenv
@pytest.mark.project
def test_activate_virtualenv_no_source(project):
def test_activate_virtualenv_no_source():
command = activate_virtualenv(source=False)
venv = project.virtualenv_location
venv = Project().virtualenv_location
assert command == '{0}/bin/activate'.format(venv)
+5 -1
View File
@@ -1,5 +1,7 @@
import os
from pipenv.project import Project
import pytest
@@ -16,7 +18,7 @@ def test_env(PipenvInstance):
@pytest.mark.run
def test_scripts(PipenvInstance, project):
def test_scripts(PipenvInstance):
with PipenvInstance(chdir=True) as p:
with open(p.pipfile_path, 'w') as f:
f.write(r"""
@@ -41,6 +43,8 @@ multicommand = "bash -c \"cd docs && make html\""
assert 'Error' in c.err
assert 'randomthingtotally (from notfoundscript)' in c.err
project = Project()
script = project.build_script('multicommand')
assert script.command == 'bash'
assert script.args == ['-c', 'cd docs && make html']
+4 -2
View File
@@ -1,5 +1,7 @@
import os
from pipenv.project import Project
import pytest
@@ -8,14 +10,14 @@ pytestmark = pytest.mark.skipif(os.name == 'nt', reason="only relevant on window
@pytest.mark.project
def test_case_changes_windows(PipenvInstance, pypi, project):
def test_case_changes_windows(PipenvInstance, pypi):
"""Test project matching for case changes on Windows.
"""
with PipenvInstance(pypi=pypi, chdir=True) as p:
c = p.pipenv('install pytz')
assert c.return_code == 0
virtualenv_location = project.virtualenv_location
virtualenv_location = Project().virtualenv_location
target = p.path.upper()
if target == p.path:
target = p.path.lower()