File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ from tempfile import TemporaryDirectory
2+ from pathlib import Path
3+ from uuid import uuid4
4+
15from ..outputs import OutputsManager
26
7+ text = '' .join ([str (i ) for i in range (10 )])
8+
9+ def so (i ):
10+ return {
11+ "output_type" : "stream" ,
12+ "name" : "stdout" ,
13+ "text" : str (i ),
14+ }
15+
16+ stream_outputs = list ([so (i ) for i in range (10 )])
17+
18+
319def test_instantiation ():
420 op = OutputsManager ()
21+ assert isinstance (op , OutputsManager )
22+
23+ def test_stream ():
24+ with TemporaryDirectory () as td :
25+ op = OutputsManager ()
26+ op .outputs_path = Path (td ) / "outputs"
27+ file_id = str (uuid4 ())
28+ cell_id = str (uuid4 ())
29+ output_index = 0
30+ assert op ._build_path (file_id , cell_id , output_index ) == \
31+ op .outputs_path / file_id / cell_id / f"{ output_index } .output"
32+ for stream in stream_outputs :
33+ op .write_stream (file_id , cell_id , stream )
34+ assert op .get_stream (file_id , cell_id ) == text
535
You can’t perform that action at this time.
0 commit comments