#NEWLINE# def test_signal_signals_weak_sender( ) : #NEWLINE# #INDENT# sentinel = Sentinel ( ) #NEWLINE# sig = blinker . Signal ( ) #NEWLINE# connected = sentinel . make_receiver ( 'receiver_connected' ) #NEWLINE# disconnected = sentinel . make_receiver ( 'receiver_disconnected' ) #NEWLINE# receiver1 = sentinel . make_receiver ( 'receiver1' ) #NEWLINE# receiver2 = sentinel . make_receiver ( 'receiver2' ) #NEWLINE# class Sender ( object ) : #NEWLINE# #INDENT# 'A weakref-able object.' #NEWLINE# #UNINDENT# sig . receiver_connected . connect ( connected ) #NEWLINE# sig . receiver_disconnected . connect ( disconnected ) #NEWLINE# sender1 = Sender ( ) #NEWLINE# sig . connect ( receiver1 , sender = sender1 , weak = False ) #NEWLINE# sig . disconnect ( receiver1 , sender = sender1 ) #NEWLINE# assert ( len ( sentinel ) == 2 ) #NEWLINE# del sentinel [ : ] #NEWLINE# sender2 = Sender ( ) #NEWLINE# sig . connect ( receiver2 , sender = sender2 , weak = False ) #NEWLINE# del sender2 #NEWLINE# collect_acyclic_refs ( ) #NEWLINE# assert ( len ( sentinel ) == 1 ) #NEWLINE# sig . send ( 'abc' ) #NEWLINE# assert ( len ( disconnected ) == 1 )