本文整理汇总了Python中pants.backend.python.interpreter_cache.PythonInterpreterCache._setup_paths方法的典型用法代码示例。如果您正苦于以下问题:Python PythonInterpreterCache._setup_paths方法的具体用法?Python PythonInterpreterCache._setup_paths怎么用?Python PythonInterpreterCache._setup_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.backend.python.interpreter_cache.PythonInterpreterCache
的用法示例。
在下文中一共展示了PythonInterpreterCache._setup_paths方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_test
# 需要导入模块: from pants.backend.python.interpreter_cache import PythonInterpreterCache [as 别名]
# 或者: from pants.backend.python.interpreter_cache.PythonInterpreterCache import _setup_paths [as 别名]
def _setup_test(self, constraints=None, mock_setup_paths_interpreters=None):
mock_setup = mock.MagicMock().return_value
type(mock_setup).interpreter_constraints = mock.PropertyMock(return_value=constraints)
with temporary_dir() as path:
mock_setup.interpreter_cache_dir = path
cache = PythonInterpreterCache(mock_setup, mock.MagicMock())
cache._setup_cached = mock.Mock(return_value=[self._interpreter])
if mock_setup_paths_interpreters:
cache._setup_paths = mock.Mock(return_value=[PythonInterpreter.from_binary(mock_setup_paths_interpreters[0]),
PythonInterpreter.from_binary(mock_setup_paths_interpreters[1])])
else:
cache._setup_paths = mock.Mock(return_value=[])
yield cache, path
示例2: _setup_test
# 需要导入模块: from pants.backend.python.interpreter_cache import PythonInterpreterCache [as 别名]
# 或者: from pants.backend.python.interpreter_cache.PythonInterpreterCache import _setup_paths [as 别名]
def _setup_test(self, constraints=None):
mock_setup = mock.MagicMock().return_value
type(mock_setup).interpreter_constraints = mock.PropertyMock(return_value=constraints)
with temporary_dir() as path:
mock_setup.interpreter_cache_dir = path
cache = PythonInterpreterCache(mock_setup, mock.MagicMock())
def set_interpreters(_):
cache._interpreters.add(self._interpreter)
cache._setup_cached = mock.Mock(side_effect=set_interpreters)
cache._setup_paths = mock.Mock()
yield cache, path
示例3: _setup_test
# 需要导入模块: from pants.backend.python.interpreter_cache import PythonInterpreterCache [as 别名]
# 或者: from pants.backend.python.interpreter_cache.PythonInterpreterCache import _setup_paths [as 别名]
def _setup_test(self, interpreter_requirement=None):
mock_setup = mock.MagicMock().return_value
# Explicitly set a repo-wide requirement that excludes our one interpreter.
type(mock_setup).interpreter_requirement = mock.PropertyMock(
return_value=interpreter_requirement)
with temporary_dir() as path:
mock_setup.interpreter_cache_dir = path
cache = PythonInterpreterCache(mock_setup, mock.MagicMock())
def set_interpreters(_):
cache._interpreters.add(self._interpreter)
cache._setup_cached = mock.Mock(side_effect=set_interpreters)
cache._setup_paths = mock.Mock()
yield cache, path
示例4: _do_test
# 需要导入模块: from pants.backend.python.interpreter_cache import PythonInterpreterCache [as 别名]
# 或者: from pants.backend.python.interpreter_cache.PythonInterpreterCache import _setup_paths [as 别名]
def _do_test(self, interpreter_requirement, filters, expected):
mock_setup = mock.MagicMock().return_value
# Explicitly set a repo-wide requirement that excludes our one interpreter.
type(mock_setup).interpreter_requirement = mock.PropertyMock(
return_value=interpreter_requirement)
with temporary_dir() as path:
mock_setup.scratch_dir = path
cache = PythonInterpreterCache(mock_setup, mock.MagicMock())
def set_interpreters(_):
cache._interpreters.add(self._interpreter)
cache._setup_cached = mock.Mock(side_effect=set_interpreters)
cache._setup_paths = mock.Mock()
self.assertEqual(cache.setup(filters=filters), expected)
示例5: test_cache_setup_with_no_filters_uses_repo_default_excluded
# 需要导入模块: from pants.backend.python.interpreter_cache import PythonInterpreterCache [as 别名]
# 或者: from pants.backend.python.interpreter_cache.PythonInterpreterCache import _setup_paths [as 别名]
def test_cache_setup_with_no_filters_uses_repo_default_excluded(self, MockSetup):
# This is the interpreter we'll inject into the cache
interpreter = PythonInterpreter.get()
mock_setup = MockSetup.return_value
# Explicitly set a repo-wide requirement that excludes our one interpreter
type(mock_setup).interpreter_requirement = mock.PropertyMock(
return_value=self._make_bad_requirement(interpreter.identity.requirement))
with temporary_dir() as path:
mock_setup.scratch_dir.return_value = path
cache = PythonInterpreterCache(mock.MagicMock())
def set_interpreters(_):
cache._interpreters.add(interpreter)
cache._setup_cached = mock.Mock(side_effect=set_interpreters)
cache._setup_paths = mock.Mock()
self.assertEqual(len(cache.setup()), 0)