@@ -918,20 +918,38 @@ def test_isolation_levels(self):
918918con .begin ('Garbage' ).commit ()
919919
920920def test_ports_management (self ):
921- # check that no ports have been bound yet
922- assert (len (bound_ports )== 0 )
921+ assert bound_ports is not None
922+ assert type (bound_ports )== set # noqa: E721
923+
924+ if len (bound_ports )!= 0 :
925+ logging .warning ("bound_ports is not empty: {0}" .format (bound_ports ))
926+
927+ stage0__bound_ports = bound_ports .copy ()
923928
924929with get_new_node ()as node :
925- # check that we've just bound a port
926- assert (len (bound_ports )== 1 )
930+ assert bound_ports is not None
931+ assert type (bound_ports )== set # noqa: E721
932+
933+ assert node .port is not None
934+ assert type (node .port )== int # noqa: E721
935+
936+ logging .info ("node port is {0}" .format (node .port ))
937+
938+ assert node .port in bound_ports
939+ assert node .port not in stage0__bound_ports
940+
941+ assert stage0__bound_ports <= bound_ports
942+ assert len (stage0__bound_ports )+ 1 == len (bound_ports )
943+
944+ stage1__bound_ports = stage0__bound_ports .copy ()
945+ stage1__bound_ports .add (node .port )
927946
928- # check that bound_ports contains our port
929- port_1 = list (bound_ports )[0 ]
930- port_2 = node .port
931- assert (port_1 == port_2 )
947+ assert stage1__bound_ports == bound_ports
932948
933949# check that port has been freed successfully
934- assert (len (bound_ports )== 0 )
950+ assert bound_ports is not None
951+ assert type (bound_ports )== set # noqa: E721
952+ assert bound_ports == stage0__bound_ports
935953
936954def test_exceptions (self ):
937955str (StartNodeException ('msg' , [('file' ,'lines' )]))