Skip to content

Commit

Permalink
Test exclude_regexp in AutocallChecker.
Browse files Browse the repository at this point in the history
  • Loading branch information
bfroehle committed May 8, 2012
1 parent d1f107f commit 9d723ae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions IPython/core/tests/test_prefilter.py
Expand Up @@ -5,6 +5,7 @@
#-----------------------------------------------------------------------------
import nose.tools as nt

from IPython.core.prefilter import AutocallChecker
from IPython.testing import tools as tt, decorators as dec
from IPython.testing.globalipapp import get_ipython

Expand Down Expand Up @@ -46,6 +47,21 @@ def test_autocall_binops():
yield nt.assert_equals(ip.prefilter('f 1'),'f(1)')
for t in ['f +1', 'f -1']:
yield nt.assert_equals(ip.prefilter(t), t)

# Run tests again with a more permissive exclude_regexp, which will
# allow transformation of binary operations ('f -1' -> 'f(-1)').
pm = ip.prefilter_manager
ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm,
config=pm.config)
try:
ac.priority = 1
ac.exclude_regexp = r'^[,&^\|\*/]|^is |^not |^in |^and |^or '
pm.sort_checkers()

yield nt.assert_equals(ip.prefilter('f -1'), 'f(-1)')
yield nt.assert_equals(ip.prefilter('f +1'), 'f(+1)')
finally:
pm.unregister_checker(ac)
finally:
ip.magic('autocall 0')
del ip.user_ns['f']
Expand Down

0 comments on commit 9d723ae

Please sign in to comment.