当前位置: 首页>>代码示例>>Python>>正文


Python virtualenv_mod.create函数代码示例

本文整理汇总了Python中salt.modules.virtualenv_mod.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_symlinks_argument

 def test_symlinks_argument(self):
     # We test for pyvenv only because with virtualenv this is un
     # unsupported option.
     mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
     with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
         virtualenv_mod.create("/tmp/foo", venv_bin="pyvenv", symlinks=True)
         mock.assert_called_once_with(["pyvenv", "--symlinks", "/tmp/foo"], runas=None, python_shell=False)
开发者ID:bryson,项目名称:salt,代码行数:7,代码来源:virtualenv_test.py

示例2: test_issue_6030_deprecated_never_download

    def test_issue_6030_deprecated_never_download(self):
        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})

        with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
            virtualenv_mod.create(
                '/tmp/foo', never_download=True
            )
            mock.assert_called_once_with(
                'virtualenv --never-download /tmp/foo',
                runas=None
            )

        with TestsLoggingHandler() as handler:
            mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
            # Let's fake a higher virtualenv version
            virtualenv_mock = MagicMock()
            virtualenv_mock.__version__ = '1.10rc1'
            with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
                with patch.dict('sys.modules',
                                {'virtualenv': virtualenv_mock}):
                    virtualenv_mod.create(
                        '/tmp/foo', never_download=True
                    )
                    mock.assert_called_once_with('virtualenv /tmp/foo',
                                                 runas=None)

                # Are we logging the deprecation information?
                self.assertIn(
                    'INFO:The virtualenv \'--never-download\' option has been '
                    'deprecated in virtualenv(>=1.10), as such, the '
                    '\'never_download\' option to `virtualenv.create()` has '
                    'also been deprecated and it\'s not necessary anymore.',
                    handler.messages
                )
开发者ID:penta-srl,项目名称:salt,代码行数:34,代码来源:virtualenv_test.py

示例3: test_issue_6031_multiple_extra_search_dirs

    def test_issue_6031_multiple_extra_search_dirs(self):
        extra_search_dirs = ["/tmp/bar-1", "/tmp/bar-2", "/tmp/bar-3"]

        # Passing extra_search_dirs as a list
        mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
        with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
            virtualenv_mod.create("/tmp/foo", extra_search_dir=extra_search_dirs)
            mock.assert_called_once_with(
                [
                    "virtualenv",
                    "--extra-search-dir=/tmp/bar-1",
                    "--extra-search-dir=/tmp/bar-2",
                    "--extra-search-dir=/tmp/bar-3",
                    "/tmp/foo",
                ],
                runas=None,
                python_shell=False,
            )

        # Passing extra_search_dirs as comma separated list
        mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
        with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
            virtualenv_mod.create("/tmp/foo", extra_search_dir=",".join(extra_search_dirs))
            mock.assert_called_once_with(
                [
                    "virtualenv",
                    "--extra-search-dir=/tmp/bar-1",
                    "--extra-search-dir=/tmp/bar-2",
                    "--extra-search-dir=/tmp/bar-3",
                    "/tmp/foo",
                ],
                runas=None,
                python_shell=False,
            )
开发者ID:bryson,项目名称:salt,代码行数:34,代码来源:virtualenv_test.py

示例4: test_get_virtualenv_version_from_shell

    def test_get_virtualenv_version_from_shell(self):
        with ForceImportErrorOn("virtualenv"):

            # ----- virtualenv binary not available ------------------------->
            mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                self.assertRaises(CommandExecutionError, virtualenv_mod.create, "/tmp/foo")
            # <---- virtualenv binary not available --------------------------

            # ----- virtualenv binary present but > 0 exit code ------------->
            mock = MagicMock(
                side_effect=[{"retcode": 1, "stdout": "", "stderr": "This is an error"}, {"retcode": 0, "stdout": ""}]
            )
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                self.assertRaises(CommandExecutionError, virtualenv_mod.create, "/tmp/foo", venv_bin="virtualenv")
            # <---- virtualenv binary present but > 0 exit code --------------

            # ----- virtualenv binary returns 1.9.1 as its version --------->
            mock = MagicMock(side_effect=[{"retcode": 0, "stdout": "1.9.1"}, {"retcode": 0, "stdout": ""}])
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                virtualenv_mod.create("/tmp/foo", never_download=True)
                mock.assert_called_with(["virtualenv", "--never-download", "/tmp/foo"], runas=None, python_shell=False)
            # <---- virtualenv binary returns 1.9.1 as its version ----------

            # ----- virtualenv binary returns 1.10rc1 as its version ------->
            mock = MagicMock(side_effect=[{"retcode": 0, "stdout": "1.10rc1"}, {"retcode": 0, "stdout": ""}])
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                virtualenv_mod.create("/tmp/foo", never_download=True)
                mock.assert_called_with(["virtualenv", "/tmp/foo"], runas=None, python_shell=False)
开发者ID:bryson,项目名称:salt,代码行数:29,代码来源:virtualenv_test.py

示例5: test_clear_argument

 def test_clear_argument(self):
     mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
     with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
         virtualenv_mod.create('/tmp/foo', clear=True)
         mock.assert_called_once_with(
             'virtualenv --clear /tmp/foo', runas=None
         )
开发者ID:penta-srl,项目名称:salt,代码行数:7,代码来源:virtualenv_test.py

示例6: test_issue_6030_deprecated_never_download

    def test_issue_6030_deprecated_never_download(self):
        mock = MagicMock(return_value={"retcode": 0, "stdout": ""})

        with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
            virtualenv_mod.create("/tmp/foo", never_download=True)
            mock.assert_called_once_with(["virtualenv", "--never-download", "/tmp/foo"], runas=None, python_shell=False)

        with TestsLoggingHandler() as handler:
            mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
            # Let's fake a higher virtualenv version
            virtualenv_mock = MagicMock()
            virtualenv_mock.__version__ = "1.10rc1"
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                with patch.dict("sys.modules", {"virtualenv": virtualenv_mock}):
                    virtualenv_mod.create("/tmp/foo", never_download=True)
                    mock.assert_called_once_with(["virtualenv", "/tmp/foo"], runas=None, python_shell=False)

                # Are we logging the deprecation information?
                self.assertIn(
                    "INFO:The virtualenv '--never-download' option has been "
                    "deprecated in virtualenv(>=1.10), as such, the "
                    "'never_download' option to `virtualenv.create()` has "
                    "also been deprecated and it's not necessary anymore.",
                    handler.messages,
                )
开发者ID:bryson,项目名称:salt,代码行数:25,代码来源:virtualenv_test.py

示例7: test_issue_6029_deprecated_distribute

    def test_issue_6029_deprecated_distribute(self):
        mock = MagicMock(return_value={"retcode": 0, "stdout": ""})

        with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
            virtualenv_mod._install_script = MagicMock(
                return_value={"retcode": 0, "stdout": "Installed script!", "stderr": ""}
            )
            virtualenv_mod.create("/tmp/foo", system_site_packages=True, distribute=True)
            mock.assert_called_once_with(
                ["virtualenv", "--distribute", "--system-site-packages", "/tmp/foo"], runas=None, python_shell=False
            )

        with TestsLoggingHandler() as handler:
            # Let's fake a higher virtualenv version
            virtualenv_mock = MagicMock()
            virtualenv_mock.__version__ = "1.10rc1"
            mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
            with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
                with patch.dict("sys.modules", {"virtualenv": virtualenv_mock}):
                    virtualenv_mod.create("/tmp/foo", system_site_packages=True, distribute=True)
                    mock.assert_called_once_with(
                        ["virtualenv", "--system-site-packages", "/tmp/foo"], runas=None, python_shell=False
                    )

                # Are we logging the deprecation information?
                self.assertIn(
                    "INFO:The virtualenv '--distribute' option has been "
                    "deprecated in virtualenv(>=1.10), as such, the "
                    "'distribute' option to `virtualenv.create()` has "
                    "also been deprecated and it's not necessary anymore.",
                    handler.messages,
                )
开发者ID:bryson,项目名称:salt,代码行数:32,代码来源:virtualenv_test.py

示例8: test_python_argument

    def test_python_argument(self):
        mock = MagicMock(return_value={"retcode": 0, "stdout": ""})

        with patch.dict(virtualenv_mod.__salt__, {"cmd.run_all": mock}):
            virtualenv_mod.create("/tmp/foo", python=sys.executable)
            mock.assert_called_once_with(
                ["virtualenv", "--python={0}".format(sys.executable), "/tmp/foo"], runas=None, python_shell=False
            )
开发者ID:bryson,项目名称:salt,代码行数:8,代码来源:virtualenv_test.py

示例9: test_get_virtualenv_version_from_shell

    def test_get_virtualenv_version_from_shell(self):
        with ForceImportErrorOn('virtualenv'):

            # ----- virtualenv binary not available ------------------------->
            mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
            with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
                self.assertRaises(
                    CommandExecutionError,
                    virtualenv_mod.create,
                    '/tmp/foo',
                )
            # <---- virtualenv binary not available --------------------------

            # ----- virtualenv binary present but > 0 exit code ------------->
            mock = MagicMock(side_effect=[
                {'retcode': 1, 'stdout': '', 'stderr': 'This is an error'},
                {'retcode': 0, 'stdout': ''}
            ])
            with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
                self.assertRaises(
                    CommandExecutionError,
                    virtualenv_mod.create,
                    '/tmp/foo',
                    venv_bin='virtualenv',
                )
            # <---- virtualenv binary present but > 0 exit code --------------

            # ----- virtualenv binary returns 1.9.1 as its version --------->
            mock = MagicMock(side_effect=[
                {'retcode': 0, 'stdout': '1.9.1'},
                {'retcode': 0, 'stdout': ''}
            ])
            with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
                virtualenv_mod.create(
                    '/tmp/foo', never_download=True
                )
                mock.assert_called_with(
                    ['virtualenv', '--never-download', '/tmp/foo'],
                    runas=None,
                    python_shell=False
                )
            # <---- virtualenv binary returns 1.9.1 as its version ----------

            # ----- virtualenv binary returns 1.10rc1 as its version ------->
            mock = MagicMock(side_effect=[
                {'retcode': 0, 'stdout': '1.10rc1'},
                {'retcode': 0, 'stdout': ''}
            ])
            with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
                virtualenv_mod.create(
                    '/tmp/foo', never_download=True
                )
                mock.assert_called_with(
                    ['virtualenv', '/tmp/foo'],
                    runas=None,
                    python_shell=False
                )
开发者ID:shineforever,项目名称:ops,代码行数:57,代码来源:virtualenv_test.py

示例10: test_symlinks_argument

 def test_symlinks_argument(self):
     # We test for pyvenv only because with virtualenv this is un
     # unsupported option.
     mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
     with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
         virtualenv_mod.create('/tmp/foo', venv_bin='pyvenv', symlinks=True)
         mock.assert_called_once_with(
             'pyvenv --symlinks /tmp/foo', runas=None
         )
开发者ID:penta-srl,项目名称:salt,代码行数:9,代码来源:virtualenv_test.py

示例11: test_python_argument

 def test_python_argument(self):
     mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
     with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
         virtualenv_mod.create(
             '/tmp/foo', python='/usr/bin/python2.7',
         )
         mock.assert_called_once_with(
             'virtualenv --python=/usr/bin/python2.7 /tmp/foo',
             runas=None
         )
开发者ID:1mentat,项目名称:salt,代码行数:10,代码来源:virtualenv_test.py

示例12: test_upgrade_argument

 def test_upgrade_argument(self):
     # We test for pyvenv only because with virtualenv this is un
     # unsupported option.
     mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
     with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
         virtualenv_mod.create('/tmp/foo', venv_bin='pyvenv', upgrade=True)
         mock.assert_called_once_with(
             ['pyvenv', '--upgrade', '/tmp/foo'],
             runas=None,
             python_shell=False
         )
开发者ID:shineforever,项目名称:ops,代码行数:11,代码来源:virtualenv_test.py

示例13: test_python_argument

    def test_python_argument(self):
        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})

        with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
            virtualenv_mod.create(
                '/tmp/foo', python=sys.executable,
            )
            mock.assert_called_once_with(
                'virtualenv --python={0} /tmp/foo'.format(sys.executable),
                runas=None
            )
开发者ID:AccelerationNet,项目名称:salt,代码行数:11,代码来源:virtualenv_test.py

示例14: test_python_argument

 def test_python_argument(self):
     mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
     if os.path.isfile('/usr/bin/python2.7'):
         python = '/usr/bin/python2.7'
     elif os.path.isfile('/usr/bin/python2.6'):
         python = '/usr/bin/python2.6'
     with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
         virtualenv_mod.create(
             '/tmp/foo', python=python,
         )
         mock.assert_called_once_with(
             'virtualenv --python={0} /tmp/foo'.format(python),
             runas=None
         )
开发者ID:penta-srl,项目名称:salt,代码行数:14,代码来源:virtualenv_test.py

示例15: test_no_site_packages_deprecation

    def test_no_site_packages_deprecation(self):
        # We *always* want *all* warnings thrown on this module
        warnings.resetwarnings()
        warnings.filterwarnings('always', '', DeprecationWarning, __name__)

        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
        with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock}):
            with warnings.catch_warnings(record=True) as w:
                virtualenv_mod.create(
                    '/tmp/foo', no_site_packages=True
                )
                self.assertEqual(
                    '\'no_site_packages\' has been deprecated. Please '
                    'start using \'system_site_packages=False\' which '
                    'means exactly the same as \'no_site_packages=True\'',
                    str(w[-1].message)
                )
开发者ID:sijis,项目名称:salt,代码行数:17,代码来源:virtualenv_test.py


注:本文中的salt.modules.virtualenv_mod.create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。