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


Python MagicMock.__version__方法代码示例

本文整理汇总了Python中salttesting.mock.MagicMock.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.__version__方法的具体用法?Python MagicMock.__version__怎么用?Python MagicMock.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在salttesting.mock.MagicMock的用法示例。


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

示例1: test_issue_6030_deprecated_never_download

# 需要导入模块: from salttesting.mock import MagicMock [as 别名]
# 或者: from salttesting.mock.MagicMock import __version__ [as 别名]
    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,代码行数:36,代码来源:virtualenv_test.py

示例2: test_issue_6029_deprecated_distribute

# 需要导入模块: from salttesting.mock import MagicMock [as 别名]
# 或者: from salttesting.mock.MagicMock import __version__ [as 别名]
    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,代码行数:34,代码来源:virtualenv_test.py

示例3: test_issue_6030_deprecated_never_download

# 需要导入模块: from salttesting.mock import MagicMock [as 别名]
# 或者: from salttesting.mock.MagicMock import __version__ [as 别名]
    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,代码行数:27,代码来源:virtualenv_test.py

示例4: test_issue_6029_deprecated_distribute

# 需要导入模块: from salttesting.mock import MagicMock [as 别名]
# 或者: from salttesting.mock.MagicMock import __version__ [as 别名]
    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:shineforever,项目名称:ops,代码行数:47,代码来源:virtualenv_test.py

示例5: import

# 需要导入模块: from salttesting.mock import MagicMock [as 别名]
# 或者: from salttesting.mock.MagicMock import __version__ [as 别名]
from salttesting.helpers import (
    ensure_in_syspath,
    TestsLoggingHandler,
    ForceImportErrorOn
)
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
ensure_in_syspath('../../')

# Import salt libs
from salt.modules import virtualenv_mod
from salt.exceptions import CommandExecutionError

virtualenv_mod.__salt__ = {}
virtualenv_mod.__opts__['venv_bin'] = 'virtualenv'
base_virtualenv_mock = MagicMock()
base_virtualenv_mock.__version__ = '1.9.1'


@skipIf(NO_MOCK, NO_MOCK_REASON)
@patch('salt.utils.which', lambda bin_name: bin_name)
@patch.dict('sys.modules', {'virtualenv': base_virtualenv_mock})
class VirtualenvTestCase(TestCase):

    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!',
开发者ID:penta-srl,项目名称:salt,代码行数:33,代码来源:virtualenv_test.py


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