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

Commit 9903f78

Browse files
authored
operation: io: Run Doctest Examples
Fixes: #524
1 parent c7eb62d commit 9903f78

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Added
9-
- Operations for taking input from the user(AcceptUserInput) and for printing the output(print_output)
9+
- Operations for taking input from the user `AcceptUserInput` and for printing the output `print_output`
1010
- Hugging Face Transformers tensorflow based NER models.
1111
- PNG ConfigLoader for reading images as arrays to predict using MNIST trained models
1212
- Docstrings and doctestable examples to `record.py`.

dffml/operation/io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AcceptUserInput(OperationImplementation):
5252
++++++++
5353
5454
The following example shows how to use AcceptUserInput.
55+
5556
>>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)
5657
>>> dataflow.seed.append(
5758
... Input(
@@ -106,6 +107,7 @@ async def print_output(data: str):
106107
++++++++
107108
108109
The following example shows how to use print_output.
110+
109111
>>> dataflow = DataFlow.auto(print_output, GetSingle)
110112
>>> inputs = [
111113
... Input(
@@ -121,4 +123,4 @@ async def print_output(data: str):
121123
print_output example
122124
String to be printed is 'print_output example'
123125
"""
124-
print("\n" + data)
126+
print(data)

docs/doctest_header.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import inspect
88
import asyncio
99
import tempfile
10+
import builtins
1011
import functools
12+
from unittest import mock
1113

1214
# Create a temporary directory for test to run in
1315
DOCTEST_TEMPDIR = tempfile.mkdtemp()
@@ -16,14 +18,18 @@
1618
# Change the current working directory to the temporary directory
1719
os.chdir(DOCTEST_TEMPDIR)
1820

19-
from dffml_model_scikit import *
2021
from dffml import *
2122
from dffml.base import *
2223
from dffml.record import *
2324
from dffml.df.base import *
2425
from dffml.df.types import *
25-
from dffml.df.memory import *
2626
from dffml.util.net import *
27+
from dffml.df.memory import *
28+
from dffml_model_scikit import *
29+
from dffml.operation.io import *
30+
from dffml.source.memory import *
2731
from dffml.operation.output import *
2832
from dffml.operation.dataflow import *
29-
from dffml.source.memory import *
33+
34+
# Used for mocking input() for AcceptUserInput operation.
35+
mock.patch("builtins.input", return_value="Data flow is awesome").start()

0 commit comments

Comments
 (0)