test that close works. it does.

This commit is contained in:
Jean-Paul Calderone 2019-02-21 13:11:44 -05:00
parent 05807ace40
commit cd3207e543

View File

@ -91,7 +91,6 @@ def assert_expected_action_tree(testcase, logger, expected_action_type, expected
"Logger had messages:\n{}".format(pformat(logger.messages, indent=4)),
)
def assert_generator_logs_action_tree(testcase, generator_function, logger, expected_action_type, expected_type_tree):
list(eliot_friendly_generator_function(generator_function)())
assert_expected_action_tree(
@ -289,6 +288,33 @@ class EliotFriendlyGeneratorFunctionTests(TestCase):
],
)
@capture_logging(None)
def test_close_generator(self, logger):
@eliot_friendly_generator_function
def g():
Message.log(message_type=u"a")
try:
yield
Message.log(message_type=u"b")
finally:
Message.log(message_type=u"c")
with start_action(action_type=u"the-action"):
gen = g()
next(gen)
gen.close()
assert_expected_action_tree(
self,
logger,
u"the-action", [
u"a",
u"yielded",
u"c",
],
)
class InlineCallbacksTests(TestCase):
# Get our custom assertion failure messages *and* the standard ones.