本文整理汇总了Python中unittest.TestCase.assertIsNotNone方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertIsNotNone方法的具体用法?Python TestCase.assertIsNotNone怎么用?Python TestCase.assertIsNotNone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertIsNotNone方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _apply
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def _apply(self,
put: unittest.TestCase,
value: Any,
message_builder: MessageBuilder):
msg = message_builder.apply('')
put.assertIsNotNone(value, msg)
put.assertIsInstance(value, self.expected_type, msg)
self.value_assertion.apply(put, value, message_builder)
示例2: _assertions
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def _assertions(self,
unittest_case: unittest.TestCase,
actual: FailureInfo):
unittest_case.assertIsNotNone(actual,
'Failure info should be present')
unittest_case.assertIsInstance(actual, PhaseFailureInfo,
'The failure is expected to be a {}'.format(str(PhaseFailureInfo)))
assert isinstance(actual, PhaseFailureInfo)
self.assertions_(unittest_case,
actual.phase_step.simple,
actual.failure_details)
示例3: create_app
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def create_app(test: unittest.TestCase) -> App:
"""
Create an :py:class:`App <arobito.controlinterface.ControllerBackend.App>` instance
:param test: The currently running unit test case
:return: An instance of App
"""
app = App()
test.assertIsNotNone(app)
test.assertIsInstance(app, App)
return app
示例4: check_result
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def check_result(put: unittest.TestCase,
environment: InstructionEnvironmentForPostSdsStep,
expected_matcher_result: Optional[ValueAssertion[str]],
actual_result: Optional[ErrorMessageResolver]):
if expected_matcher_result is None:
put.assertIsNone(actual_result,
'result from main')
else:
put.assertIsNotNone(actual_result,
'result from main')
err_msg_env = ErrorMessageResolvingEnvironment(environment.home_and_sds,
environment.symbols)
err_msg = actual_result.resolve(err_msg_env)
expected_matcher_result.apply_with_message(put, err_msg,
'error result of main')
示例5: _assertions
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def _assertions(self,
unittest_case: unittest.TestCase,
return_value: Failure):
if self._status is PartialExeResultStatus.PASS:
unittest_case.assertIsNone(return_value,
'Return value must be None (representing success)')
else:
unittest_case.assertIsNotNone(return_value,
'Return value must not be None (representing failure)')
unittest_case.assertEqual(self._status,
return_value.status,
'Status')
self._line.apply_with_message(unittest_case,
return_value.source_location,
'source location path')
unittest_case.assertIsNotNone(return_value.failure_details,
'failure_details must be present')
self._failure_details.apply_with_message(unittest_case,
return_value.failure_details,
'failure_details')
示例6: get_valid_key
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [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
示例7: assert_velocity_properties
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def assert_velocity_properties(test_case: unittest.TestCase, data: SeismicData,
velocity_prop: VelocityProperties) -> None:
test_case.assertIsNotNone(data)
test_case.assertIsNotNone(data.velocity_properties)
test_case.assertIsNotNone(velocity_prop)
for prop in dir(data.velocity_properties):
if "_" in prop[0:1] or prop == "count" or prop == "index":
continue
if getattr(data.velocity_properties, prop) is None:
test_case.assertIsNone(getattr(velocity_prop, prop))
else:
try:
float(getattr(data.velocity_properties, prop))
test_case.assertAlmostEqual(getattr(data.velocity_properties, prop),
getattr(velocity_prop, prop), 3)
except ValueError:
test_case.assertEqual(getattr(data.velocity_properties, prop),
getattr(velocity_prop, prop))
示例8: assertIsNotNone
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsNotNone [as 别名]
def assertIsNotNone(self, obj, msg=None):
if hasattr(TestCase, 'assertIsNotNone'):
return TestCase.assertIsNotNone(self, obj, msg)
return self.assertTrue(obj is not None)