cubicweb/devtools/testlib.py
branch3.26
changeset 12577 2508ba96fad2
parent 12250 afc678253bc2
child 12591 f5f83d72ba8d
child 12719 9fb4a71f119d
equal deleted inserted replaced
12565:8ef162b039a0 12577:2508ba96fad2
   477         if email is not None:
   477         if email is not None:
   478             req.create_entity('EmailAddress', address=text_type(email),
   478             req.create_entity('EmailAddress', address=text_type(email),
   479                               reverse_primary_email=user)
   479                               reverse_primary_email=user)
   480         user.cw_clear_relation_cache('in_group', 'subject')
   480         user.cw_clear_relation_cache('in_group', 'subject')
   481         if commit:
   481         if commit:
   482             try:
   482             getattr(req, 'cnx', req).commit()
   483                 req.commit()  # req is a session
       
   484             except AttributeError:
       
   485                 req.cnx.commit()
       
   486         return user
   483         return user
   487 
   484 
   488     # other utilities #########################################################
   485     # other utilities #########################################################
   489 
   486 
   490     @contextmanager
   487     @contextmanager