MCPcopy Create free account
hub / github.com/hugapi/hug / test_exception

Method test_exception

tests/test_context_factory.py:322–346  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

320 assert custom_context["test_number"] == 44
321
322 def test_exception(self):
323 custom_context = dict(test="context")
324
325 @hug.context_factory()
326 def return_context(**kwargs):
327 return custom_context
328
329 @hug.delete_context()
330 def delete_context(context, exception=None, errors=None, lacks_requirement=None):
331 assert context == custom_context
332 assert exception
333 assert isinstance(exception, CustomException)
334 assert not errors
335 assert not lacks_requirement
336 custom_context["launched_delete_context"] = True
337
338 @hug.cli()
339 def exception_local_function():
340 custom_context["launched_local_function"] = True
341 raise CustomException()
342
343 hug.test.cli(exception_local_function)
344
345 assert "launched_local_function" in custom_context
346 assert "launched_delete_context" in custom_context
347
348 def test_success(self):
349 custom_context = dict(test="context")

Callers

nothing calls this directly

Calls 1

cliMethod · 0.45

Tested by

no test coverage detected