本文整理汇总了Python中unittest.mock.Mock.label方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.label方法的具体用法?Python Mock.label怎么用?Python Mock.label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.Mock
的用法示例。
在下文中一共展示了Mock.label方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_by_label
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def test_by_label( self ):
s0, s1 = Mock( spec=SymmetryOperation ), Mock( spec=SymmetryOperation )
s0.label = 'A'
s1.label = 'B'
sg = SymmetryGroup( symmetry_operations=[ s0, s1 ] )
self.assertEqual( sg.by_label( 'A' ), s0 )
self.assertEqual( sg.by_label( 'B' ), s1 )
示例2: test_included_axes_list_with_fact
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def test_included_axes_list_with_fact(self, members, _, fact):
"""
Tests the additional axis inclusions with a fact.
"""
mock_fact = Mock()
fact.return_value = [mock_fact]
mock_error_func = Mock()
mock_model_xbrl = Mock(error=mock_error_func)
mock_val = Mock(modelXbrl=mock_model_xbrl)
mock_config = {
'additional_axes': {
'foo': ['trey', 'page', 'mike', 'fish']
},
'rule_index': 100
}
mock_qname = Mock(localName='jerry')
mock_child = Mock(qname=mock_qname)
members.return_value = [mock_child]
mock_axis = Mock()
mock_role = 'RoDriftBoats'
dqc_us_0001._run_member_checks(
mock_axis,
Mock(),
mock_config,
Mock(),
mock_val,
mock_role,
defaultdict(list)
)
self.assertTrue(mock_error_func.called)
mock_error_func.assert_called_with(
'{base}.{index}'.format(base=dqc_us_0001._CODE_NAME, index=100),
dqc_us_0001.messages.get_message(
dqc_us_0001._CODE_NAME,
dqc_us_0001._UGT_FACT_KEY
),
axis=mock_axis.label(),
member=mock_child.label(),
modelObject=mock_fact,
ruleVersion=dqc_us_0001._RULE_VERSION
)
示例3: test_has_ext_none_allowed_has_fact
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def test_has_ext_none_allowed_has_fact(self, members, _, fact):
"""
Tests extension blacklisting with a fact.
"""
mock_fact = Mock()
fact.return_value = [mock_fact]
mock_error_func = Mock()
mock_model_xbrl = Mock(error=mock_error_func)
mock_val = Mock(modelXbrl=mock_model_xbrl)
mock_qname = Mock(localName='jerry')
mock_child = Mock(qname=mock_qname)
members.return_value = [mock_child]
mock_axis = Mock()
mock_role = 'RoDriftBoats'
mock_config = {
"extensions": [],
'rule_index': 100
}
dqc_us_0001._run_extension_checks(
mock_axis,
Mock(),
mock_config,
Mock(),
mock_val,
mock_role,
defaultdict(list)
)
self.assertTrue(mock_error_func.called)
mock_error_func.assert_called_with(
'{base}.{index}'.format(base=dqc_us_0001._CODE_NAME, index=100),
dqc_us_0001.messages.get_message(
dqc_us_0001._CODE_NAME,
dqc_us_0001._EXT_FACT_KEY
),
axis=mock_axis.label(),
member=mock_child.label(),
modelObject=mock_fact,
ruleVersion=dqc_us_0001._RULE_VERSION
)
示例4: test_excluded_list_no_fact
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def test_excluded_list_no_fact(self, members, _, __):
"""
Tests excluded axes without a fact.
"""
mock_error_func = Mock()
mock_model_xbrl = Mock(error=mock_error_func)
mock_val = Mock(modelXbrl=mock_model_xbrl)
mock_config = {
'excluded_axes': {
'foo': ['trey', 'page', 'mike', 'fish']
},
'rule_index': 100
}
mock_qname = Mock(localName='trey')
mock_child = Mock(qname=mock_qname)
members.return_value = [mock_child]
mock_axis = Mock()
mock_role = 'RoDriftBoats'
dqc_us_0001._run_member_checks(
mock_axis,
mock_config,
Mock(),
mock_val,
mock_role
)
self.assertTrue(mock_error_func.called)
mock_error_func.assert_called_with(
'{base}.{index}'.format(base=dqc_us_0001._CODE_NAME, index=100),
dqc_us_0001.messages.get_message(
dqc_us_0001._CODE_NAME,
dqc_us_0001._NO_FACT_KEY
),
axis=mock_axis.label(),
group='RoDriftBoats',
member=mock_child.label(),
ruleVersion=dqc_us_0001._RULE_VERSION
)
示例5: filter_by_mock_concept
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def filter_by_mock_concept(**kwargs):
filter_mock = Mock()
concept_id = None
conceptscheme_id = None
if 'concept_id' in kwargs:
concept_id = kwargs['concept_id']
if 'conceptscheme_id' in kwargs:
conceptscheme_id = kwargs['conceptscheme_id']
if concept_id == '1':
c = Concept(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
c.type = 'concept'
label_mock = Mock()
label_mock.label = 'test'
c.label = Mock(return_value=label_mock)
filter_mock.one = Mock(return_value=c)
elif concept_id == '3':
c = Collection(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
c.type = 'collection'
label_mock = Mock()
label_mock.label = 'test'
c.label = Mock(return_value=label_mock)
filter_mock.one = Mock(return_value=c)
elif concept_id == '555':
c = Thing(concept_id=concept_id, conceptscheme_id=conceptscheme_id)
filter_mock.one = Mock(return_value=c)
elif concept_id == '666':
raise NoResultFound
a_concept = Concept(concept_id=7895, conceptscheme_id=conceptscheme_id, type='concept')
a_labels = [Label(label='De Paardekastanje', language_id='nl'), Label(label='The Chestnut', language_id='en'),
Label(label='la châtaigne', language_id='fr')]
a_concept.labels = a_labels
b_concept = Concept(concept_id=9863, conceptscheme_id=conceptscheme_id, type='concept')
b_labels = [Label(label='test', language_id='nl')]
b_concept.labels = b_labels
filter_mock.all = Mock(return_value=[a_concept, b_concept])
return filter_mock
示例6: Mock
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
ns_num_68_mock.straat_id = 48086
ns_num_68_mock.huisnummer = "68"
ns_num_68_mock.subadressen = [ns_num_69_sub_mock]
ns_num_68_mock.postkanton = pk_8300_mock
ns_num_69_mock = Mock()
ns_num_69_mock.id = 882821
ns_num_69_mock.straat_id = 43086
ns_num_69_mock.huisnummer = "69"
ns_num_69_mock.subadressen = []
ns_num_69_mock.postkanton = pk_8300_mock
nieuwstraat_mock = Mock()
nieuwstraat_mock.id = 48086
nieuwstraat_mock.gemeente_id = 191
nieuwstraat_mock.label = "Nieuwstraat"
nieuwstraat_mock.huisnummers = [ns_num_6_mock, ns_num_68_mock]
knokke_mock = Mock()
knokke_mock.id = 191
knokke_mock.naam = "Knokke-Heist"
knokke_mock.straten = [nieuwstraat_mock]
knokke_mock.postkantons = [pk_8300_mock, pk_8301_mock]
# Lier
pk_2500_mock = Mock()
pk_2500_mock.id = 2500
lier_mock = Mock()
lier_mock.id = 36
示例7: test_labels
# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import label [as 别名]
def test_labels( self ):
s0, s1 = Mock( spec=SymmetryOperation ), Mock( spec=SymmetryOperation )
s0.label = 'A'
s1.label = 'B'
sg = SymmetryGroup( symmetry_operations=[ s0, s1 ] )
self.assertEqual( sg.labels, [ 'A', 'B' ] )