@@ -750,3 +750,70 @@ def func1(in1):
750750
751751 os .chdir (cwd )
752752 rmtree (wd )
753+
754+
755+ def test_write_graph_runs ():
756+ cwd = os .getcwd ()
757+ wd = mkdtemp ()
758+ os .chdir (wd )
759+
760+ for graph in ('orig' , 'flat' , 'exec' , 'hierarchical' , 'colored' ):
761+ for simple in (True , False ):
762+ pipe = pe .Workflow (name = 'pipe' )
763+ mod1 = pe .Node (interface = TestInterface (), name = 'mod1' )
764+ mod2 = pe .Node (interface = TestInterface (), name = 'mod2' )
765+ pipe .connect ([(mod1 , mod2 , [('output1' , 'input1' )])])
766+ try :
767+ pipe .write_graph (graph2use = graph , simple_form = simple )
768+ except Exception :
769+ yield assert_true , False , \
770+ 'Failed to plot {} {} graph' .format (
771+ 'simple' if simple else 'detailed' , graph )
772+
773+ yield assert_true , os .path .exists ('graph.dot' ) or os .path .exists ('graph_detailed.dot' )
774+ try :
775+ os .remove ('graph.dot' )
776+ except OSError :
777+ pass
778+ try :
779+ os .remove ('graph_detailed.dot' )
780+ except OSError :
781+ pass
782+
783+ os .chdir (cwd )
784+ rmtree (wd )
785+
786+ def test_deep_nested_write_graph_runs ():
787+ cwd = os .getcwd ()
788+ wd = mkdtemp ()
789+ os .chdir (wd )
790+
791+ for graph in ('orig' , 'flat' , 'exec' , 'hierarchical' , 'colored' ):
792+ for simple in (True , False ):
793+ pipe = pe .Workflow (name = 'pipe' )
794+ parent = pipe
795+ for depth in range (10 ):
796+ sub = pe .Workflow (name = 'pipe_nest_{}' .format (depth ))
797+ parent .add_nodes ([sub ])
798+ parent = sub
799+ mod1 = pe .Node (interface = TestInterface (), name = 'mod1' )
800+ parent .add_nodes ([mod1 ])
801+ try :
802+ pipe .write_graph (graph2use = graph , simple_form = simple )
803+ except Exception as e :
804+ yield assert_true , False , \
805+ 'Failed to plot {} {} deep graph: {!s}' .format (
806+ 'simple' if simple else 'detailed' , graph , e )
807+
808+ yield assert_true , os .path .exists ('graph.dot' ) or os .path .exists ('graph_detailed.dot' )
809+ try :
810+ os .remove ('graph.dot' )
811+ except OSError :
812+ pass
813+ try :
814+ os .remove ('graph_detailed.dot' )
815+ except OSError :
816+ pass
817+
818+ os .chdir (cwd )
819+ rmtree (wd )
0 commit comments