def test_autocall_binops():
 ip.magic('autocall 2')
 f = (lambda x: x)
 ip.user_ns['f'] = f
 try:
  nt.assert_equal(ip.prefilter('f 1'), 'f(1)')
  for t in ['f +1', 'f -1']:
   nt.assert_equal(ip.prefilter(t), t)
  pm = ip.prefilter_manager
  ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm, config=pm.config)
  try:
   ac.priority = 1
   ac.exclude_regexp = '^[,&^\\|\\*/]|^is |^not |^in |^and |^or '
   pm.sort_checkers()
   nt.assert_equal(ip.prefilter('f -1'), 'f(-1)')
   nt.assert_equal(ip.prefilter('f +1'), 'f(+1)')
  finally:
   pm.unregister_checker(ac)
 finally:
  ip.magic('autocall 0')
  del ip.user_ns['f']

def test_autocall_binops ( ) : ip . magic ( 'autocall 2' ) f = ( lambda x : x ) ip . user_ns [ 'f' ] = f try : nt . assert_equal ( ip . prefilter ( 'f 1' ) , 'f(1)' ) for t in [ 'f +1' , 'f -1' ] : nt . assert_equal ( ip . prefilter ( t ) , t ) pm = ip . prefilter_manager ac = AutocallChecker ( shell = pm . shell , prefilter_manager = pm , config = pm . config ) try : ac . priority = 1 ac . exclude_regexp = '^[,&^\\|\\*/]|^is |^not |^in |^and |^or ' pm . sort_checkers ( ) nt . assert_equal ( ip . prefilter ( 'f -1' ) , 'f(-1)' ) nt . assert_equal ( ip . prefilter ( 'f +1' ) , 'f(+1)' ) finally : pm . unregister_checker ( ac ) finally : ip . magic ( 'autocall 0' ) del ip . user_ns [ 'f' ]
see URL .