Show More
@@ -5,6 +5,7 | |||||
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
6 | import nose.tools as nt |
|
6 | import nose.tools as nt | |
7 |
|
7 | |||
|
8 | from IPython.core.prefilter import AutocallChecker | |||
8 | from IPython.testing import tools as tt, decorators as dec |
|
9 | from IPython.testing import tools as tt, decorators as dec | |
9 | from IPython.testing.globalipapp import get_ipython |
|
10 | from IPython.testing.globalipapp import get_ipython | |
10 |
|
11 | |||
@@ -46,6 +47,21 def test_autocall_binops(): | |||||
46 | yield nt.assert_equals(ip.prefilter('f 1'),'f(1)') |
|
47 | yield nt.assert_equals(ip.prefilter('f 1'),'f(1)') | |
47 | for t in ['f +1', 'f -1']: |
|
48 | for t in ['f +1', 'f -1']: | |
48 | yield nt.assert_equals(ip.prefilter(t), t) |
|
49 | yield nt.assert_equals(ip.prefilter(t), t) | |
|
50 | ||||
|
51 | # Run tests again with a more permissive exclude_regexp, which will | |||
|
52 | # allow transformation of binary operations ('f -1' -> 'f(-1)'). | |||
|
53 | pm = ip.prefilter_manager | |||
|
54 | ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm, | |||
|
55 | config=pm.config) | |||
|
56 | try: | |||
|
57 | ac.priority = 1 | |||
|
58 | ac.exclude_regexp = r'^[,&^\|\*/]|^is |^not |^in |^and |^or ' | |||
|
59 | pm.sort_checkers() | |||
|
60 | ||||
|
61 | yield nt.assert_equals(ip.prefilter('f -1'), 'f(-1)') | |||
|
62 | yield nt.assert_equals(ip.prefilter('f +1'), 'f(+1)') | |||
|
63 | finally: | |||
|
64 | pm.unregister_checker(ac) | |||
49 | finally: |
|
65 | finally: | |
50 | ip.magic('autocall 0') |
|
66 | ip.magic('autocall 0') | |
51 | del ip.user_ns['f'] |
|
67 | del ip.user_ns['f'] |
General Comments 0
You need to be logged in to leave comments.
Login now