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


Python Mock.name方法代码示例

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


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

示例1: test_multiple_plugins

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
def test_multiple_plugins(iter_entry_points):
    plugin1 = Mock()
    plugin1.name = 'plugin1'
    plugin1.dist.project_name = 'mymodule'
    plugin2 = Mock()
    plugin2.name = 'plugin2'
    plugin2.dist.project_name = 'mymodule'
    plugin3 = Mock()
    plugin3.name = 'plugin3'
    plugin3.dist.project_name = 'mymodule'
    iter_entry_points.return_value = [plugin2, plugin3, plugin1]
    config = ConfigParser()
    config.read_dict({
        'whatever': dict(plugins='mymodule#plugin1,mymodule#plugin2'),
        'whatever_reverse': dict(plugins='mymodule#plugin2,mymodule#plugin1'),
        'other': dict(plugins='mymodule#plugin2,mymodule#plugin3'),
            })
    plugins = load(config, 'whatever')
    plugin1.load.assert_called_once_with(require=False)
    assert plugins == [('mymodule#plugin1', plugin1.load()), ('mymodule#plugin2', plugin2.load())]
    # reverse order in the config file and you see the plugins are returned in that order
    plugins = load(config, 'whatever_reverse')
    assert plugins == [('mymodule#plugin2', plugin2.load()), ('mymodule#plugin1', plugin1.load())]
    # try now with only one plugin configured
    assert not plugin3.load.called
    plugins = load(config, 'other')
    plugin3.load.assert_called_once_with(require=False)
    assert plugins == [('mymodule#plugin2', plugin2.load()), ('mymodule#plugin3', plugin3.load())]
开发者ID:ingted,项目名称:zgres,代码行数:30,代码来源:test_plugin.py

示例2: model

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
def model():
    artist = Mock()
    artist.name = 'Test Artist'

    album = Mock(ignored=False, artist=artist)
    album.name = 'Test Album'

    return library.AlbumModel(album, 1.0)
开发者ID:thesquelched,项目名称:suggestive,代码行数:10,代码来源:test_library.py

示例3: test_str

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
    def test_str(self):
        """Test string reprezentation of an instance."""
        source_node = Mock()
        source_node.name = 'node_S'

        target_node = Mock()
        target_node.name = 'node_T'

        event = self._make_instance(source_node, target_node, 'replica_XYZ')

        self.assertEqual(
            str(event),
            "<ReceiveReplicaRequest event> (node_S --> node_T, replica_XYZ)"
        )
开发者ID:plamut,项目名称:datagrid,代码行数:16,代码来源:test_event.py

示例4: test_str_target_is_none

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
    def test_str_target_is_none(self):
        """Test string reprezentation of an instance when target node is None.
        """
        source_node = Mock()
        source_node.name = 'node_S'

        replica = Mock()
        replica.name = 'replica_XYZ'

        event = self._make_instance(source_node, None, replica)

        self.assertEqual(
            str(event),
            "<SendReplica event> (None <-- node_S, replica_XYZ)"
        )
开发者ID:plamut,项目名称:datagrid,代码行数:17,代码来源:test_event.py

示例5: test_refresh_job_outdated

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
def test_refresh_job_outdated(JENKINS):
    from jenkins_epo.extensions.jenkins import CreateJobsExtension
    from jenkins_epo.bot import Instruction

    ext = CreateJobsExtension('createjob', Mock())
    ext.current = ext.bot.current
    ext.current.errors = []
    ext.current.refresh_jobs = None
    ext.current.job_specs = {'job': Mock(config={})}
    ext.current.job_specs['job'].name = 'job'
    job = Mock(updated_at=datetime.now() - timedelta(hours=1))
    job.name = 'job'
    job.spec.contains.return_value = True
    job.update = CoroutineMock()
    ext.current.jobs = {'job': job}

    ext.process_instruction(Instruction(
        author='author', name='refresh-jobs', date=datetime.now()
    ))

    assert ext.current.refresh_jobs

    items = list(ext.process_job_specs())
    assert 1 == len(items)
    action, spec = items[0]
    assert job.update == action

    ext.current.jobs['job'].updated_at = datetime.now() + timedelta(hours=1)
    items = list(ext.process_job_specs())
    assert 0 == len(items)
开发者ID:novafloss,项目名称:jenkins-github-poller,代码行数:32,代码来源:test_create_jobs.py

示例6: setUp

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
 def setUp(self):
     """
     Set up values for the unit tests that follow
     """
     mock_type = Mock()
     mock_type.name = 'textBlockItemType'
     mock_qname = Mock(
         return_value=(
             '{http://xbrl.sec.gov/dei/2014-01-31}DocumentFiscalPeriodFocus'
         ),
         namespaceURI='http://xbrl.sec.gov/dei/2014-01-31',
         localName='DocumentFiscalPeriodFocus'
     )
     mock_concept = Mock(qname=mock_qname, type=mock_type)
     mock_nameconcepts = {'DocumentFiscalPeriodFocus': [mock_concept]}
     mock_context = Mock()
     mock_fact = Mock(
         context=mock_context,
         concept=mock_concept,
         qname=mock_qname,
         xValue='Q3'
     )
     mock_factsbyqname = {mock_concept.qname: [mock_fact]}
     self.mock_model = Mock(
         factsByQname=mock_factsbyqname,
         facts=[mock_fact],
         nameConcepts=mock_nameconcepts
     )
开发者ID:andrewperkins-wf,项目名称:dqc_us_rules,代码行数:30,代码来源:test_dqc_us_0006.py

示例7: setUp

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
 def setUp(self):
     """
     Sets up values for the unit tests
     """
     mock_type = Mock()
     mock_type.name = 'textBlockItemType'
     mock_qname = Mock(
         return_value=(
             '{http://fasb.org/us-gaap/2015-01-31}DocumentPeriodEndDate'
         ),
         namespaceURI='http://fasb.org/us-gaap/2015-01-31',
         localName='DocumentPeriodEndDate')
     mock_concept = Mock(qname=mock_qname,
                         type=mock_type)
     mock_nameconcepts = {'DocumentPeriodEndDate': [mock_concept]}
     mock_segdimval = {}
     mock_context = Mock(
         endDatetime=date(2015, 1, 1),
         segDimValues=mock_segdimval
     )
     mock_fact = Mock(
         context=mock_context,
         concept=mock_concept,
         xValue=date(2015, 1, 1)
     )
     mock_factsbyqname = {mock_concept.qname: [mock_fact]}
     self.mock_disclosure = Mock(
         standardTaxonomiesDict={'http://fasb.org/us-gaap/2015-01-31': None}
     )
     self.mock_model = Mock(
         factsByQname=mock_factsbyqname,
         facts=[mock_fact],
         nameConcepts=mock_nameconcepts
     )
开发者ID:andrewperkins-wf,项目名称:dqc_us_rules,代码行数:36,代码来源:test_facts.py

示例8: setUp

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
 def setUp(self):
     mock_type = Mock()
     mock_type.name = 'textBlockItemType'
     mock_qname = Mock(
         return_value=(
             '{http://xbrl.sec.gov/dei/2014-01-31}DocumentPeriodEndDate'
         ),
         namespaceURI='http://xbrl.sec.gov/dei/2014-01-31',
         localName='DocumentPeriodEndDate'
     )
     mock_concept = Mock(
         qname=mock_qname, type=mock_type
     )
     mock_nameConcepts = {'DocumentPeriodEndDate': [mock_concept]}
     mock_segDimVal = {}
     mock_context = Mock(
         endDatetime=date(2015, 1, 1),
         segDimValues=mock_segDimVal
     )
     mock_fact = Mock(
         context=mock_context,
         concept=mock_concept,
         xValue=date(2015, 1, 1)
     )
     mock_factsByQname = {mock_concept.qname: [mock_fact]}
     self.mock_disclosure = Mock(
         standardTaxonomiesDict={'http://xbrl.sec.gov/dei/2014-01-31': None}
     )
     self.mock_model = Mock(
         factsByQname=mock_factsByQname,
         facts=[mock_fact],
         nameConcepts=mock_nameConcepts
     )
开发者ID:Workiva,项目名称:dqc_us_rules,代码行数:35,代码来源:test_dqc_us_0005.py

示例9: test_build_failed

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
def test_build_failed(mocker, SETTINGS):
    JENKINS = mocker.patch('jenkins_epo.extensions.jenkins.JENKINS')

    from jenkins_epo.extensions.jenkins import BuilderExtension

    ext = BuilderExtension('builder', Mock())
    ext.current = ext.bot.current
    job = Mock()
    job.build = CoroutineMock(side_effect=Exception('POUET'))
    spec = Mock(config=dict())
    spec.name = 'job'
    ext.current.SETTINGS = SETTINGS
    ext.current.head.ref = 'refs/heads/pr'
    ext.current.last_commit.filter_not_built_contexts.return_value = ['job']
    ext.current.last_commit.maybe_update_status = CoroutineMock(return_value={
        'description': 'Queued'
    })
    ext.current.jobs_match = []
    ext.current.job_specs = {'job': spec}
    ext.current.jobs = {'job': job}
    ext.current.statuses = {}

    JENKINS.is_queue_empty = CoroutineMock(return_value=True)

    yield from ext.run()

    assert ext.current.last_commit.maybe_update_status.mock_calls
    assert job.build.mock_calls
开发者ID:novafloss,项目名称:jenkins-github-poller,代码行数:30,代码来源:test_jenkins.py

示例10: test_add_gene_logs_debug_message

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
 def test_add_gene_logs_debug_message(self, mock_getLogger):
     mock_logger = Mock()
     mock_getLogger.return_value = mock_logger
     foo_enabler = self.TestEnabler()
     mock_organism_1 = Mock(spec=Organism())
     mock_organism_1.name = 'mock_organism_name'
     foo_enabler.decorate(mock_organism_1)
     mock_logger.debug.assert_called_with('Adding gene TestEnabler to organism "mock_organism_name"')
开发者ID:jhevans,项目名称:evolution,代码行数:10,代码来源:test_base_genes.py

示例11: test_issue_icon_color

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
 def test_issue_icon_color(self):
     issue = models.Issue()
     self.assertEqual("", issue.icon_color("blue"))
     mock_file = Mock()
     mock_file.name = 'somepath/to/icons/area/filename.bob.sVG'
     issue.icon = mock_file
     self.assertEqual('somepath/to/icons/area/filename.bob-blue.sVG',
                      issue.icon_color('blue'))
开发者ID:Threespot,项目名称:peacecorps-site,代码行数:10,代码来源:test_models.py

示例12: resolve_view

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
    def resolve_view(req, res, tail):
        async def view_call():
            return 'view_result'

        mock = Mock(name='view')
        mock.name = 'view'
        mock.return_value = view_call()
        return mock
开发者ID:zzzsochi,项目名称:aiohttp_traversal,代码行数:10,代码来源:test_router.py

示例13: test_create_event

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
async def test_create_event():
    """Successfully created a deCONZ event."""
    hass = Mock()
    remote = Mock()
    remote.name = 'Name'

    event = gateway.DeconzEvent(hass, remote)

    assert event._id == 'name'
开发者ID:boced66,项目名称:home-assistant,代码行数:11,代码来源:test_gateway.py

示例14: test_do_not_add_deconz_groups

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
async def test_do_not_add_deconz_groups(hass):
    """Test that clip sensors can be ignored."""
    await setup_gateway(hass, {}, allow_deconz_groups=False)
    group = Mock()
    group.name = 'name'
    group.register_async_callback = Mock()
    async_dispatcher_send(hass, 'deconz_new_group', [group])
    await hass.async_block_till_done()
    assert len(hass.data[deconz.DOMAIN].deconz_ids) == 0
开发者ID:ManHammer,项目名称:home-assistant,代码行数:11,代码来源:test_light.py

示例15: _mock_calendar

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import name [as 别名]
def _mock_calendar(name):
    events = []
    for idx, event in enumerate(EVENTS):
        events.append(Event(None, "%d.ics" % idx, event, None, str(idx)))

    calendar = Mock()
    calendar.date_search = MagicMock(return_value=events)
    calendar.name = name
    return calendar
开发者ID:DavidMStraub,项目名称:home-assistant,代码行数:11,代码来源:test_caldav.py


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