本文整理汇总了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'])
示例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'])
示例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)
示例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)
示例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})
示例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'])
示例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'])
]
示例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]
)
示例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)
示例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)
示例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)
示例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)
)