Changeset 9802ee4 in trunk
- Timestamp:
- 2019-03-07T18:30:29Z (6 years ago)
- Branches:
- master
- Children:
- 5de4f40
- Parents:
- f4950cf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/test/test_eliotutil.py ¶
rf4950cf r9802ee4 22 22 from testtools.matchers import ( 23 23 Is, 24 IsInstance, 24 25 MatchesStructure, 25 26 Equals, … … 29 30 has_no_result, 30 31 succeeded, 32 failed, 31 33 ) 32 34 … … 56 58 eliot_friendly_generator_function, 57 59 inline_callbacks, 60 log_call_deferred, 58 61 _parse_destination_description, 59 62 _EliotLogging, … … 528 531 ), 529 532 ) 533 534 class LogCallDeferredTests(TestCase): 535 """ 536 Tests for ``log_call_deferred``. 537 """ 538 @capture_logging( 539 lambda self, logger: 540 assertHasAction(self, logger, u"the-action", succeeded=True), 541 ) 542 def test_return_value(self, logger): 543 """ 544 The decorated function's return value is passed through. 545 """ 546 result = object() 547 @log_call_deferred(action_type=u"the-action") 548 def f(): 549 return result 550 self.assertThat(f(), succeeded(Is(result))) 551 552 @capture_logging( 553 lambda self, logger: 554 assertHasAction(self, logger, u"the-action", succeeded=False), 555 ) 556 def test_raise_exception(self, logger): 557 """ 558 An exception raised by the decorated function is passed through. 559 """ 560 class Result(Exception): 561 pass 562 @log_call_deferred(action_type=u"the-action") 563 def f(): 564 raise Result() 565 self.assertThat( 566 f(), 567 failed( 568 AfterPreprocessing( 569 lambda f: f.value, 570 IsInstance(Result), 571 ), 572 ), 573 )
Note: See TracChangeset
for help on using the changeset viewer.