Show More
@@ -510,6 +510,12 b' class AutocallChecker(PrefilterChecker):' | |||
|
510 | 510 | if not oinfo['found']: |
|
511 | 511 | return None |
|
512 | 512 | |
|
513 | ignored_funs = ['b', 'f', 'r', 'u', 'br', 'rb', 'fr', 'rf'] | |
|
514 | ifun = line_info.ifun | |
|
515 | line = line_info.line | |
|
516 | if ifun.lower() in ignored_funs and (line.startswith(ifun + "'") or line.startswith(ifun + '"')): | |
|
517 | return None | |
|
518 | ||
|
513 | 519 | if callable(oinfo['obj']) \ |
|
514 | 520 | and (not self.exclude_regexp.match(line_info.the_rest)) \ |
|
515 | 521 | and self.function_name_regexp.match(line_info.ifun): |
@@ -5,7 +5,14 b' directory, which we are removing. For now putting this here ensures at least' | |||
|
5 | 5 | we do run the test, though ultimately this functionality should all be tested |
|
6 | 6 | with better-isolated tests that don't rely on the global instance in iptest. |
|
7 | 7 | """ |
|
8 | from IPython.core.splitinput import LineInfo | |
|
9 | from IPython.core.prefilter import AutocallChecker | |
|
8 | 10 | from IPython.utils import py3compat |
|
11 | from IPython.testing.globalipapp import get_ipython | |
|
12 | ||
|
13 | ||
|
14 | ip = get_ipython() | |
|
15 | ||
|
9 | 16 | |
|
10 | 17 | @py3compat.doctest_refactor_print |
|
11 | 18 | def doctest_autocall(): |
@@ -18,28 +25,49 b' def doctest_autocall():' | |||
|
18 | 25 | ...: return a + a |
|
19 | 26 |
...: |
|
20 | 27 | |
|
21 |
In [3]: |
|
|
22 | Out[3]: 'a b ca b c' | |
|
28 | In [3]: def r(x): | |
|
29 | ...: return True | |
|
30 | ...: | |
|
31 | ||
|
32 | In [4]: ;f2 a b c | |
|
33 | Out[4]: 'a b ca b c' | |
|
23 | 34 | |
|
24 |
In [ |
|
|
35 | In [5]: assert _ == "a b ca b c" | |
|
25 | 36 | |
|
26 |
In [ |
|
|
27 |
Out[ |
|
|
37 | In [6]: ,f1 a b c | |
|
38 | Out[6]: 'abc' | |
|
28 | 39 | |
|
29 |
In [ |
|
|
40 | In [7]: assert _ == 'abc' | |
|
30 | 41 | |
|
31 |
In [ |
|
|
42 | In [8]: print _ | |
|
32 | 43 | abc |
|
33 | 44 | |
|
34 |
In [ |
|
|
35 |
Out[ |
|
|
45 | In [9]: /f1 1,2,3 | |
|
46 | Out[9]: 6 | |
|
47 | ||
|
48 | In [10]: assert _ == 6 | |
|
36 | 49 | |
|
37 | In [9]: assert _ == 6 | |
|
50 | In [11]: /f2 4 | |
|
51 | Out[11]: 8 | |
|
38 | 52 | |
|
39 | In [10]: /f2 4 | |
|
40 | Out[10]: 8 | |
|
53 | In [12]: assert _ == 8 | |
|
41 | 54 | |
|
42 |
In [1 |
|
|
55 | In [12]: del f1, f2 | |
|
43 | 56 | |
|
44 |
In [1 |
|
|
57 | In [13]: ,r a | |
|
58 | Out[13]: True | |
|
59 | ||
|
60 | In [14]: assert _ == True | |
|
61 | ||
|
62 | In [15]: r'a' | |
|
63 | Out[15]: 'a' | |
|
64 | ||
|
65 | In [16]: assert _ == 'a' | |
|
45 | 66 | """ |
|
67 | ||
|
68 | ||
|
69 | def test_autocall_should_ignore_raw_strings(): | |
|
70 | line_info = LineInfo("r'a'") | |
|
71 | pm = ip.prefilter_manager | |
|
72 | ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm, config=pm.config) | |
|
73 | assert ac.check(line_info) is None |
General Comments 0
You need to be logged in to leave comments.
Login now