[tahoe-lafs-trac-stream] [Tahoe-LAFS] #2777: modernize tests, use "mock"
Tahoe-LAFS
trac at tahoe-lafs.org
Fri Apr 22 16:42:19 UTC 2016
#2777: modernize tests, use "mock"
------------------------+-----------------------
Reporter: warner | Owner:
Type: task | Status: new
Priority: minor | Milestone: undecided
Component: code | Version: 1.11.0
Resolution: | Keywords:
Launchpad Bug: |
------------------------+-----------------------
Comment (by warner):
Glyph also pointed me at newer assertion methods, like:
* `f = self.failureResultOf(d, *expectedExceptionTypes)`: passes iff the
Deferred has already errbacked, with one of the given types
* `res = self.successResultOf(d)`: passes iff the Deferred has already
callbacked
* `self.assertNoResult(d)`: passes iff the Deferred has not been fired yet
The general pattern is to avoid waiting for Deferreds as much as possible.
You call the method that returns a Deferred (with mocks in place for
everything it might wait upon), then you manually trigger those mocks.
Before, during, and after the triggers, you keep inspecting the Deferred
to make sure it's in the right state.
--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2777#comment:3>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage
More information about the tahoe-lafs-trac-stream
mailing list