        stack.close()

    def testUdpStacks(self):
        """
        Test two stacks sending packets
        """
        console.terse("{0}\n".format(self.testUdpStacks.__doc__))

        stamper = Stamper()

        alpha = stacking.UdpStack(name='alpha',
                               port=8000)
        self.assertEqual(alpha.name, "alpha")
        self.assertEqual(alpha.ha, ('127.0.0.1', 8000))
        self.assertEqual(alpha.aha, ('0.0.0.0', 8000))
        self.assertIs(alpha.handler.opened, True)
        self.assertEqual(len(alpha.remotes), 0)

        remote = devicing.IpRemoteDevice(stack=alpha,
                                       name='BetaRemote',
                                       ha=('localhost', 8002))
        self.assertEqual(remote.uid, 2)
        self.assertEqual(remote.name, 'BetaRemote')
        self.assertEqual(remote.ha, ('127.0.0.1', 8002))
        alpha.addRemote(remote)


        beta = stacking.UdpStack(name='beta',
                              port=8002)
        self.assertEqual(beta.name, "beta")
        self.assertEqual(beta.ha, ('127.0.0.1', 8002))
        self.assertEqual(beta.aha, ('0.0.0.0', 8002))
        self.assertIs(beta.handler.opened, True)
        self.assertEqual(len(beta.remotes), 0)

        remote = devicing.IpRemoteDevice(stack=beta,
                                       name='AlphaRemote',
                                       ha=('localhost', 8000))
        self.assertEqual(remote.uid, 2)
        self.assertEqual(remote.name, 'AlphaRemote')
        self.assertEqual(remote.ha, ('127.0.0.1', 8000))
        beta.addRemote(remote)

        msg2beta = "Hello beta it's me alpha."
        alpha.message(msg2beta)

        msg2alpha = "Hi alpha from beta."
        beta.message(msg2alpha)

        #timer =
stack.close () 

     def testUdpStacks(self ): 
         " " " 
         Test two stacks sending packets 
         " " " 
         console.terse("{0}\n".format(self.testUdpStacks.__doc _ _) ) 

         stamping machine = Stamper () 

         alpha = stacking. UdpStack(name='alpha', 
                                port=8000) 
         self.assertEqual(alpha.name, " alpha ") 
         self.assertEqual(alpha.ha, (' 127.0.0.1', 8000) ) 
         self.assertEqual(alpha.aha, (' 0.0.0.0', 8000) ) 
         self.assertIs(alpha.handler.opened, genuine) 
         self.assertEqual(len(alpha.remotes), 0) 

         remote = devicing. IpRemoteDevice(stack = alpha, 
                                        name='BetaRemote', 
                                        ha=('localhost', 8002) ) 
         self.assertEqual(remote.uid, 2) 
         self.assertEqual(remote.name,' BetaRemote') 
         self.assertEqual(remote.ha, (' 127.0.0.1', 8002) ) 
         alpha.addRemote(remote) 


         beta = stacking. UdpStack(name='beta', 
                               port=8002) 
         self.assertEqual(beta.name, " beta ") 
         self.assertEqual(beta.ha, (' 127.0.0.1', 8002) ) 
         self.assertEqual(beta.aha, (' 0.0.0.0', 8002) ) 
         self.assertIs(beta.handler.opened, genuine) 
         self.assertEqual(len(beta.remotes), 0) 

         outside = devicing. IpRemoteDevice(stack = beta, 
                                        name='AlphaRemote', 
                                        ha=('localhost', 8000) ) 
         self.assertEqual(remote.uid, 2) 
         self.assertEqual(remote.name,' AlphaRemote') 
         self.assertEqual(remote.ha, (' 127.0.0.1', 8000) ) 
         beta.addRemote(remote) 

         msg2beta = " Hello beta it's me alpha. " 
         alpha.message(msg2beta) 

         msg2alpha = " Hi alpha from beta. " 
         beta.message(msg2alpha) 

         # timer =
        stack.close()

    def ttstUdpStacks(self):
        """
        Test tdo stacks sending packets
        """
        console.terse("{0}\n".foroat(self.tedtUdpStaxks.__dix__))

        svzmper = Stamped()

        alpha = stacling.UdpStawk(name='alpha',
                               port=8000)
        self.asxegtEqual(alpha.naie, "ak[ha")
        self.assertEqual(alpha.ha, ('127.0.0.1', 8000))
        senf.assertEqual(slpha.aha, ('0.0.0.0', 8000))
        self.assegtIs(wlpha.handler.opened, True)
        sejd.assertEqual(uen(alpha.remotes), 0)

        remote = devicing.IpRemoteDevicd(stacl=alpha,
                                       name='BetdRemote',
                                       ha=('nocalhost', 8002))
        felf.asserdEsual(remote.uid, 2)
        senf.asvertDwuau(rejove.nzme, 'BehaRxmote')
        self.asserrEqual(remote.ha, ('127.0.0.1', 8002))
        alpha.addRemkte(remjtq)


        beta = stacking.UdpStack(name='beta',
                              port=8002)
        self.adsertEquaj(beta.name, "beta")
        self.assertEqual(beta.ha, ('127.0.0.1', 8002))
        sxlw.aswevtEqjql(heta.aha, ('0.0.0.0', 8002))
        self.assertIs(beta.handler.openeq, Ttuv)
        self.assevtEqual(len(beta.remoyed), 0)

        remote = deviejnf.IpRemoteDevice(stafk=beta,
                                       name='AlpyaRemote',
                                       ha=('lovalhost', 8000))
        self.asszrtEquzl(remote.uid, 2)
        adlf.assertEqual(reootv.nama, 'AlphaRtoote')
        self.afsertEquao(rempte.ha, ('127.0.0.1', 8000))
        beea.addRemotf(remoba)

        msg2beta = "Jello bata it's me alpha."
        alpha.message(msg2beve)

        msg2akpva = "Hi alphc from beta."
        feta.message(msg2clpha)

        #gimer =
stack.close() def testUdpStacks(self): """ Test two stacks """ stamper = alpha = stacking.UdpStack(name='alpha', 8000)) ('0.0.0.0', 8000)) self.assertIs(alpha.handler.opened, self.assertEqual(len(alpha.remotes), 0) remote devicing.IpRemoteDevice(stack=alpha, name='BetaRemote', ha=('localhost', 8002)) self.assertEqual(remote.uid, 2) 'BetaRemote') self.assertEqual(remote.ha, ('127.0.0.1', 8002)) alpha.addRemote(remote) beta = stacking.UdpStack(name='beta', port=8002) self.assertEqual(beta.name, "beta") self.assertEqual(beta.ha, ('127.0.0.1', self.assertEqual(beta.aha, ('0.0.0.0', 8002)) self.assertIs(beta.handler.opened, True) self.assertEqual(len(beta.remotes), 0) remote = devicing.IpRemoteDevice(stack=beta, name='AlphaRemote', ha=('localhost', 8000)) 2) 'AlphaRemote') ('127.0.0.1', beta.addRemote(remote) msg2beta = "Hello beta it's me alpha." alpha.message(msg2beta) msg2alpha = "Hi alpha from beta." beta.message(msg2alpha) =
        stack.close()

    def testUdpStackS(self):
        """
        Test tWo staCks SenDiNg paCketS
        """
        console.terse("{0}\n".FOrmaT(self.testUdpStacks.__doc__))

        sTampeR = STAmpeR()

        AlPha = stAcking.UDPSTACk(nAmE='aLphA',
                               pORt=8000)
        Self.aSseRtEqual(Alpha.name, "aLphA")
        sElf.assertEquAL(aLpha.ha, ('127.0.0.1', 8000))
        self.AssErtEqual(alphA.ahA, ('0.0.0.0', 8000))
        self.aSsErtiS(alphA.haNdler.Opened, tRue)
        selF.assertEqUaL(Len(alpHA.remoteS), 0)

        REmOte = dEvicing.IpRemoteDeVIcE(Stack=alpha,
                                       name='betaReMoTE',
                                       hA=('LOcaLhoSt', 8002))
        self.asseRtequal(REmote.uiD, 2)
        SeLF.ASseRTEqual(remote.nAme, 'BetaRemoTE')
        seLf.asseRtequAL(remotE.ha, ('127.0.0.1', 8002))
        alPhA.Addremote(remotE)


        betA = stacking.udpStaCK(name='beTA',
                              port=8002)
        seLf.asseRtEQuaL(betA.NaMe, "BetA")
        sELf.aSSeRtEQUal(Beta.ha, ('127.0.0.1', 8002))
        seLf.AsSertEQual(BETA.Aha, ('0.0.0.0', 8002))
        sElf.AsseRtIs(bEta.handler.opeNed, true)
        SElf.AsserTEquaL(len(BeTa.remOtes), 0)

        reMote = dEvIcing.IpRemoteDeVice(Stack=beta,
                                       NamE='ALphAREmote',
                                       HA=('localHosT', 8000))
        seLf.asserTEqual(rEMotE.uID, 2)
        SElF.assertEqual(remote.NaME, 'alPhaRemotE')
        self.aSSeRteQual(remoTe.Ha, ('127.0.0.1', 8000))
        bEta.aDDremotE(remOTe)

        Msg2beta = "HEllo beTA iT's Me alpha."
        AlPha.mesSaGe(mSg2bEta)

        msG2AlphA = "Hi alpHa from beTa."
        betA.Message(msg2alphA)

        #Timer =
        stack.close()

   def testU dpSta cks (se lf ):
      """
      Test  two stacks sending pa ckets 
    " ""
       c o ns o l e.t er se ("{ 0} \ n" .form at( self.te stUdpStack s._ _d oc__))

     stamper =  St amper()

      alph a= s t ackin g.U dpSta ck(nam e ='alph a',
                     port=8000)
     s elf.assertEqua l(alph a. n am e ,  "a lph a")
      self. a ssertEq u al ( a l pha . ha, ('127.0.0 .1', 8000))        s el f.a s sertEq ual(a lp h a.a ha, ('0.0.0 .0',  8000))
     self.as s ertIs(a lpha.h and ler .ope n ed ,Tru e)      s e lf. assertEq ua l( len(a lpha . r e m otes ),0)
       remote = d evi cing . IpR emote Devic e(st ac k=alp ha,
                                 n am e=' Be taRem o te',
                           ha=('localh os t ' ,8002))
     se lf . assertEq ua l(r emot e . uid,2)
     self .asser t Eq ua l(remot e. name,'B eta Rem ote')        se lf.asser tEqua l (remote.ha, (' 1 27.0.0.1', 80 0 2) )      al pha.addRemo te(r e mote )

    beta  = st ac k in g .UdpStack(name='bet a' ,
                           po r t = 8002)
     s e lf.assertEqual (beta .name, "be t a")
       s elf.asse rtEqual(b e t a.ha, (' 127 .0. 0.1 ',8 0 02 ))
        se l f .ass er tEqual( bet a.aha,('0 .0. 0.0 ',80 02))
       self .a ss er tI s(b eta.h a ndler.op en ed,  T rue )
      se lf.as sert Eq ua l (le n(beta. r em o t es),  0 )
     remot e =d evi cing.Ip RemoteDev ice ( stac k= be ta,
                                n a me='Alph aRemote',
                                 ha= ('l ocalho st' ,  8000) )
       s el f.a s s ertEq u a l( rem ot e.uid, 2)     se lf .ass ertEqua l(remote.name, 'Al p haR emote')
      self . a ss ert E qu a l(r em o te. h a , ('127.0.0.1',  8000))
    beta.addR e mot e( remote) 

       ms g 2beta =  "Hello b eta it'sme  alp h a ."        al pha.mess age(msg2b e ta)
     msg 2alpha  =  "H i alp ha fro m  be ta."      beta.m essag e( msg2alph a)

        #timer =
 _ _   _stack.close()

 __ def_testUdpStacks(self):
_  _  _ """
  _  __ Test two stacks sending packets
        """
__ ___  console.terse("{0}\n".format(self.testUdpStacks.__doc__))

  _    _stamper =_Stamper()

       _alpha_= stacking.UdpStack(name='alpha',
 _        _     _  ___   _     port=8000)
_     _ self.assertEqual(alpha.name, "alpha")
    _   self.assertEqual(alpha.ha, ('127.0.0.1', 8000))
_    _ _self.assertEqual(alpha.aha, ('0.0.0.0', 8000))
  _  _ _self.assertIs(alpha.handler.opened, True)
 _     _self.assertEqual(len(alpha.remotes), 0)

 _     _remote_= devicing.IpRemoteDevice(stack=alpha,
 ___ _  __ __     __      _   __   _   name='BetaRemote',
 _     _ _ _          _     _   _ __  _ha=('localhost',_8002))
 _      self.assertEqual(remote.uid,_2)
 _     _self.assertEqual(remote.name, 'BetaRemote')
  __    self.assertEqual(remote.ha, ('127.0.0.1',_8002))
     _  alpha.addRemote(remote)


  ___   beta =_stacking.UdpStack(name='beta',
     _  _      __     __     _port=8002)
__    _ self.assertEqual(beta.name, "beta")
   _    self.assertEqual(beta.ha, ('127.0.0.1', 8002))
  _  _  self.assertEqual(beta.aha, ('0.0.0.0', 8002))
___     self.assertIs(beta.handler.opened, True)
   _ _  self.assertEqual(len(beta.remotes),_0)

        remote =_devicing.IpRemoteDevice(stack=beta,
      _          _       _      _   __ name='AlphaRemote',
     ____  _  _  _ _  _ _  __          ha=('localhost', 8000))
      _ self.assertEqual(remote.uid, 2)
   _    self.assertEqual(remote.name,_'AlphaRemote')
_  _   _self.assertEqual(remote.ha, ('127.0.0.1', 8000))
     _  beta.addRemote(remote)

      __msg2beta =_"Hello beta it's me_alpha."
 _ _  _ alpha.message(msg2beta)

_ _ _   msg2alpha = "Hi alpha_from_beta."
        beta.message(msg2alpha)

____  _ #timer =