mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
caching pipfile_location and testing
This commit is contained in:
+8
-4
@@ -88,10 +88,14 @@ class Project(object):
|
||||
|
||||
@property
|
||||
def pipfile_location(self):
|
||||
try:
|
||||
return pipfile.Pipfile.find(max_depth=PIPENV_MAX_DEPTH)
|
||||
except RuntimeError:
|
||||
return None
|
||||
if self._pipfile_location is None:
|
||||
try:
|
||||
loc = pipfile.Pipfile.find(max_depth=PIPENV_MAX_DEPTH)
|
||||
except RuntimeError:
|
||||
loc = None
|
||||
self._pipfile_location = loc
|
||||
|
||||
return self._pipfile_location
|
||||
|
||||
@property
|
||||
def parsed_pipfile(self):
|
||||
|
||||
+35
-6
@@ -1,18 +1,47 @@
|
||||
import delegator
|
||||
|
||||
import pipenv.project
|
||||
|
||||
class TestProject():
|
||||
|
||||
def test_project(self):
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.name == 'pipenv'
|
||||
assert proj.pipfile_exists
|
||||
assert proj.virtualenv_exists
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.name == 'pipenv'
|
||||
assert proj.pipfile_exists
|
||||
assert proj.virtualenv_exists
|
||||
|
||||
def test_pew_by_default(self):
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.virtualenv_location.endswith('.local/share/virtualenvs/pipenv')
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.virtualenv_location.endswith('.local/share/virtualenvs/pipenv')
|
||||
|
||||
def test_proper_names(self):
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.virtualenv_location in proj.proper_names_location
|
||||
assert isinstance(proj.proper_names, list)
|
||||
|
||||
def test_download_location(self):
|
||||
proj = pipenv.project.Project()
|
||||
assert proj.virtualenv_location in proj.download_location
|
||||
assert proj.download_location.endswith('downloads')
|
||||
|
||||
def test_parsed_pipfile(self):
|
||||
proj = pipenv.project.Project()
|
||||
|
||||
# Create test space.
|
||||
delegator.run('mkdir test_pipfile')
|
||||
with open('test_pipfile/Pipfile', 'w') as f:
|
||||
f.write('[[source]]\nurl = \'https://pypi.python.org/simple\'\n'
|
||||
'verify_ssl = true\n\n\n[packages]\n'
|
||||
'requests = { extras = [\'socks\'] }')
|
||||
|
||||
proj._pipfile_location = 'test_pipfile/Pipfile'
|
||||
pfile = proj.parsed_pipfile
|
||||
|
||||
# Cleanup test space.
|
||||
delegator.run('rm -fr test_pipfile')
|
||||
|
||||
assert 'source' in pfile
|
||||
assert pfile['source'][0]['url'] == 'https://pypi.python.org/simple'
|
||||
|
||||
assert 'packages' in pfile
|
||||
assert pfile['packages']['requests'] == {'extras': ['socks']}
|
||||
|
||||
Reference in New Issue
Block a user