本文整理汇总了Python中unittest.TestCase.assertIn方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertIn方法的具体用法?Python TestCase.assertIn怎么用?Python TestCase.assertIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertIn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _apply
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def _apply(self,
put: unittest.TestCase,
actual_phase_2_step_2_recorded_value,
message_builder: asrt.MessageBuilder):
put.assertIsInstance(actual_phase_2_step_2_recorded_value, dict,
'actual value should be a dictionary')
for phase in sorted(self.expected_phase_2_step_2_recorded_value.keys(),
key=attrgetter('value')):
put.assertIn(phase, self.expected_phase_2_step_2_recorded_value)
expected_steps = self.expected_phase_2_step_2_recorded_value[phase]
actual = actual_phase_2_step_2_recorded_value[phase]
for expected_step in sorted(expected_steps.keys()):
put.assertIn(expected_step, actual, 'Phase {}: Missing step: {}'.format(phase, expected_step))
put.assertEqual(expected_steps[expected_step],
actual[expected_step],
'{}/{}'.format(phase, expected_step))
put.assertEqual(len(expected_steps),
len(actual),
'Actual number of recorded steps for phase {} must not exceed expected'.format(phase))
put.assertEqual(len(self.expected_phase_2_step_2_recorded_value),
len(actual_phase_2_step_2_recorded_value),
'Actual number of recorded phases must not exceed expected')
# To be sure that above code does not miss any case
put.assertEqual(self.expected_phase_2_step_2_recorded_value,
actual_phase_2_step_2_recorded_value,
'Recordings per phase and step')
示例2: _assert_table_contains
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def _assert_table_contains(put: unittest.TestCase,
table: sut.SymbolTable,
expected_symbol: NameAndValue):
put.assertTrue(table.contains(expected_symbol.name),
'table SHOULD contain the value')
put.assertIn(expected_symbol.name,
table.names_set,
'names set should contain the value')
put.assertIs(expected_symbol.value,
table.lookup(expected_symbol.name),
'lookup should fins the value')
示例3: test_deleteHuds
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def test_deleteHuds(self):
TestCase.assertIn(self,
self.game.tilemap.layers.by_name['playerHud'],
self.game.tilemap.layers)
TestCase.assertIn(self,
'playerHud',
self.game.tilemap.layers.by_name)
# TODO: deleteHuds devrait retourner ce qu'il enleve pour simplifier
# les tests.
self.game.deleteHuds()
TestCase.assertNotIn(self,
'playerHud',
self.game.tilemap.layers.by_name)
示例4: get_valid_key
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def get_valid_key(test: unittest.TestCase, app: App=None) -> str:
"""
Produce a valid key by using the arobito default credentials against the :py:meth:`App.auth
<arobito.controlinterface.ControllerBackend.App.auth>` method
:param test: The currently running unit test case
:return: A valid key
"""
if app is None:
app = create_app(test)
request_valid = dict(username='arobito', password='arobito')
response = app.auth(request_valid)
test.assertIsNotNone(response, 'Response is none')
test.assertIsInstance(response, dict, 'Response is not a dict')
test.assertIn('auth', response, 'Response does not contain an auth element')
auth = response['auth']
test.assertIn('key', auth, 'Auth object does not contain a key')
key = auth['key']
test.assertIsNotNone(key, 'Key is None')
test.assertIsInstance(key, str, 'Key is not a String')
test.assertRegex(key, '^[a-zA-Z0-9]{64}$', 'Key looks not like expected')
return key
示例5: evaluate_user_object
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def evaluate_user_object(test: unittest.TestCase, user_object: dict) -> None:
"""
Helper function for evaluating an user object
:param test: The currently running test case
:param user_object: The user object to evaluate
"""
test.assertIn("username", user_object, "User name is not in the user object")
test.assertEqual(user_object["username"], "arobito", 'User name in user object is not "arobito"')
test.assertIn("level", user_object, "User level is not in user object")
test.assertEqual(user_object["level"], "Administrator", 'User level is not "Administrator"')
test.assertIn("timestamp", user_object, "Timestamp is not in user object")
test.assertIn("last_access", user_object, "Last access timestamp is not in user object")
test.assertIsInstance(user_object["timestamp"], float, "Timestamp is not a float")
test.assertIsInstance(user_object["last_access"], float, "Last access is not a float")
test.assertTrue(
user_object["timestamp"] <= user_object["last_access"], "Timestamp is not less or equal the last access"
)
示例6: assertIn
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def assertIn(self, member, container, msg=None):
if hasattr(TestCase, 'assertIn'):
return TestCase.assertIn(self, member, container, msg)
return self.assertTrue(member in container)
示例7: test_charge_monstres
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIn [as 别名]
def test_charge_monstres(self):
monstres = self.game.charge_monstres()
TestCase.assertIn(self, monstres[0], self.game.monster_layer)