Using pjsua2 with pytest - Scope problem of EndPoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I'm trying to set up some tests using pjsua2 and pytest. However I encountered some problems with EndPoints and Accounts. I took the standard pjsua2 Python demo ( and tried to make some structure of it.

The example below works fine. However if I make the created EndPoint object global by removing the "#", then the "onRegState" callback is not called.


My problem is that if I try to use the same EndPoint for two tests with two different accounts, then my account classes does not work.

import time
import pjsua2 as pj
from pjsua2 import Account

# Subclass to extend the Account and get notifications etc.
class myAccount(Account):
  def onRegState(self, prm):

def _EndPoint():
        ep_cfg = pj.EpConfig()
        ep_cfg.uaConfig.threadCnt = 0
        # global ep
        ep = pj.Endpoint()

        # Create SIP transport. Error handling sample is shown
        sipTpConfig = pj.TransportConfig();
        sipTpConfig.port = 5060;
        ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTpConfig);
        # Start the library
        return ep

def account():
  acfg = pj.AccountConfig();
  acfg.idUri = "sip:test@xxxxxxxxx";
  acfg.regConfig.registrarUri = "";
  acfg.idUri = "sip:u1@";
  acfg.regConfig.registrarUri = "sip:";
  cred = pj.AuthCredInfo("digest", "*", "test", 0, "pwtest");
  acfg.sipConfig.authCreds.append( cred );
  # Create the account
  acc = myAccount();
  return acc

def pjsua2_test():
  e = _EndPoint()
  a = account()

-------------------- Med Liberalistiske Hilsner ----------------------
   Civilingeniør, Kjeld Flarup - Mit sind er mere åbent end min tegnebog
   Sofienlundvej 6B, 7560 Hjerm, Tlf: 40 29 41 49
   Den ikke akademiske hjemmeside for liberalismen -

Visit our blog:

pjsip mailing list

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux