#NEWLINE# def test_valid( self ) : #NEWLINE# #INDENT# 'A valid address is retrieved.' #NEWLINE# virnetwork = mock . Mock ( ) #NEWLINE# hypervisor = mock . Mock ( ) #NEWLINE# virnetwork . XMLDesc . side_effect = ( lambda x : '<a><ip address="192.168.{}.1"/></a>' . format ( random . randint ( 1 , 256 ) ) ) #NEWLINE# hypervisor . listNetworks . return_value = ( 'foo' , 'bar' , 'baz' ) #NEWLINE# hypervisor . networkLookupByName . return_value = virnetwork #NEWLINE# self . assertTrue ( ( network . valid_address ( hypervisor ) in [ '192.168.{}.1' . format ( i ) for i in range ( 1 , 256 ) ] ) )