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


Python MagicMock.test方法代码示例

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


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

示例1: test_run_tests_with_test_arg

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests_with_test_arg(self, check_call):
     mock_args = MagicMock(name="args")
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = False
     mock_args.test = 'opal.tests.foo'
     test_runner._run_py_tests(mock_args)
     check_call.assert_called_once_with(['python', 'runtests.py', 'opal.tests.foo'])
开发者ID:mattstibbs,项目名称:opal,代码行数:9,代码来源:test_core_test_runner.py

示例2: test_run_tests_failfast

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests_failfast(self, check_call):
     mock_args = MagicMock(name='args')
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = False
     mock_args.test = False
     mock_args.failfast = True
     test_runner._run_py_tests(mock_args)
     check_call.assert_called_with(['python', 'runtests.py', '--failfast'])
开发者ID:openhealthcare,项目名称:opal,代码行数:10,代码来源:test_core_test_runner.py

示例3: test_run_tests_errors

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests_errors(self, exiter, check_call):
     mock_args = MagicMock(name="args")
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = False
     mock_args.test = None
     check_call.side_effect = subprocess.CalledProcessError(None, None)
     test_runner._run_py_tests(mock_args)
     exiter.assert_called_once_with(1)
开发者ID:mattstibbs,项目名称:opal,代码行数:10,代码来源:test_core_test_runner.py

示例4: test_run_tests_with_coverage_errors

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests_with_coverage_errors(self, exiter, check_call):
     mock_args = MagicMock(name="args")
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = True
     mock_args.test = None
     check_call.side_effect = [None, subprocess.CalledProcessError(None, None)]
     test_runner._run_py_tests(mock_args)
     self.assertEqual(2, check_call.call_count)
     exiter.assert_called_once_with(1)
开发者ID:mattstibbs,项目名称:opal,代码行数:11,代码来源:test_core_test_runner.py

示例5: test_handles_malformed_xml_errors

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_handles_malformed_xml_errors(self, mock_requests):
     post_return_value = MagicMock()
     post_return_value.status_code = 404
     post_return_value.reason = 'dunno'
     post_return_value.test = 'Bad XML'
     post_return_value.ok = False
     mock_requests.post.return_value = post_return_value
     with self.assertRaises(EutilsNCBIError):
         pmid = 1234569
         self.qs.efetch(args={'db': 'pubmed', 'id': pmid})
开发者ID:biocommons,项目名称:eutils,代码行数:12,代码来源:test_eutils_queryservice.py

示例6: test_run_tests_for_app_with_test

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
    def test_run_tests_for_app_with_test(self, has_file, check_call):
        mock_args = MagicMock(name="args")
        mock_args.userland_here = ffs.Path('.')
        mock_args.coverage = False
        mock_args.test = 'foo.tests.bar'

        has_file.side_effect = lambda a, b: b == 'manage.py'

        test_runner._run_py_tests(mock_args)
        check_call.assert_called_with(['python', 'manage.py', 'test', 'foo.tests.bar'])
开发者ID:mattstibbs,项目名称:opal,代码行数:12,代码来源:test_core_test_runner.py

示例7: test_run_tests_with_coverage_and_test_arg

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests_with_coverage_and_test_arg(self, check_call):
     mock_args = MagicMock(name="args")
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = True
     mock_args.test = 'opal.tests.foo'
     mock_args.failfast = False
     test_runner._run_py_tests(mock_args)
     calls = [
         call(['coverage', 'run', 'runtests.py', 'opal.tests.foo']),
         call(['coverage', 'html'])
     ]
开发者ID:openhealthcare,项目名称:opal,代码行数:13,代码来源:test_core_test_runner.py

示例8: test_run_tests

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
 def test_run_tests(self, check_call):
     mock_args = MagicMock(name="args")
     mock_args.userland_here = ffs.Path('.')
     mock_args.coverage = False
     mock_args.test = None
     test_runner.TRAVIS = False
     test_runner._run_js_tests(mock_args)
     self.assertEqual(
         ['karma', 'start', 'config/karma.conf.js', '--single-run'],
         check_call.call_args[0][0]
     )
开发者ID:mattstibbs,项目名称:opal,代码行数:13,代码来源:test_core_test_runner.py

示例9: test_run_tests_for_unknown_config

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
    def test_run_tests_for_unknown_config(self, sysexit, writer, has_file):
        mock_args = MagicMock(name="args")
        mock_args.userland_here = ffs.Path('.')
        mock_args.coverage = False
        mock_args.test = None

        has_file.return_value = False

        test_runner._run_py_tests(mock_args)
        writer.assert_any_call("\n\nCripes!\n")
        sysexit.assert_called_with(1)
开发者ID:mattstibbs,项目名称:opal,代码行数:13,代码来源:test_core_test_runner.py

示例10: test_run_tests_with_coverage

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
    def test_run_tests_with_coverage(self, check_call):
        mock_args = MagicMock(name="args")
        mock_args.userland_here = ffs.Path('.')
        mock_args.coverage = True
        mock_args.test = None
        test_runner._run_py_tests(mock_args)
        calls = [
            call(['coverage', 'run', 'runtests.py']),
            call(['coverage', 'html'])
        ]

        check_call.assert_has_calls(calls)
开发者ID:mattstibbs,项目名称:opal,代码行数:14,代码来源:test_core_test_runner.py

示例11: test_run_tests_for_app_with_coverage

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
    def test_run_tests_for_app_with_coverage(self, has_file, check_call):
        mock_args = MagicMock(name="args")
        mock_args.userland_here = ffs.Path('.')
        mock_args.coverage = True
        mock_args.test = None

        has_file.side_effect = lambda a, b: b == 'manage.py'

        test_runner._run_py_tests(mock_args)
        calls = [
            call(['coverage', 'run', 'manage.py', 'test']),
            call(['coverage', 'html'])
        ]

        check_call.assert_has_calls(calls)
开发者ID:mattstibbs,项目名称:opal,代码行数:17,代码来源:test_core_test_runner.py

示例12: test_run_tests_travis

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import test [as 别名]
    def test_run_tests_travis(self, check_call):
        mock_args = MagicMock(name="args")
        mock_args.userland_here = ffs.Path('.')
        mock_args.coverage = False
        mock_args.test = None
        test_runner.TRAVIS = True
        test_runner._run_js_tests(mock_args)
        self.assertEqual(
            [
                './node_modules/karma/bin/karma',
                'start',
                'config/karma.conf.js',
                '--single-run'
            ],
            check_call.call_args[0][0]
        )
        self.assertIn("OPAL_LOCATION", check_call.call_args[1]["env"])

        self.assertTrue(
            isinstance(check_call.call_args[1]["env"]["OPAL_LOCATION"], str)
        )
开发者ID:mattstibbs,项目名称:opal,代码行数:23,代码来源:test_core_test_runner.py


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