Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 57c340c

Browse files
committed
base: Fix doctests
Signed-off-by: John Andersen <[email protected]>
1 parent d907d69 commit 57c340c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

dffml/base.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ class BaseDataFlowFacilitatorObjectContext(LoggingLogger):
484484
classes which support async context management. Classes ending with
485485
...Context are the most inner context's which are used in DFFML.
486486
487-
>>> # Calling obj returns an instance which is a subclass of this class,
488-
>>> # BaseDataFlowFacilitatorObjectContext.
489-
>>> async with obj() as ctx:
490-
>>> await ctx.method()
487+
See the :class:BaseDataFlowFacilitatorObject for example usage.
491488
"""
492489

493490
async def __aenter__(self) -> "BaseDataFlowFacilitatorObjectContext":
@@ -516,9 +513,18 @@ class BaseDataFlowFacilitatorObject(
516513
>>> # setup. Call obj to get an instance of obj.CONTEXT, which is a subclass
517514
>>> # of BaseDataFlowFacilitatorObjectContext. ctx, the inner context, does
518515
>>> # all the heavy lifting.
519-
>>> async with BaseDataFlowObject() as obj:
520-
>>> async with obj() as ctx:
521-
>>> await ctx.method()
516+
>>> class Context(BaseDataFlowFacilitatorObjectContext):
517+
... async def method(self):
518+
... return
519+
>>> class Object(BaseDataFlowFacilitatorObject):
520+
... CONTEXT = Context
521+
... def __call__(self):
522+
... return Context()
523+
>>> async def main():
524+
... async with Object(BaseConfig()) as obj:
525+
... async with obj() as ctx:
526+
... await ctx.method()
527+
>>> asyncio.run(main())
522528
"""
523529

524530
def __init__(self, config: BaseConfig) -> None:

0 commit comments

Comments
 (0)