diff --git a/IPython/testing/plugin/dtexample.py b/IPython/testing/plugin/dtexample.py index 453aac3..7ac81cd 100644 --- a/IPython/testing/plugin/dtexample.py +++ b/IPython/testing/plugin/dtexample.py @@ -3,6 +3,7 @@ This file just contains doctests both using plain python and IPython prompts. All tests should be loaded by nose. """ +from IPython.utils.py3compat import doctest_refactor_print def pyfunc(): """Some pure python tests... @@ -23,7 +24,7 @@ def pyfunc(): """ return 'pyfunc' - +@doctest_refactor_print def ipfunc(): """Some ipython tests... @@ -127,7 +128,7 @@ def random_all(): """ pass - +@doctest_refactor_print def iprand(): """Some ipython tests with random output. @@ -142,7 +143,7 @@ def iprand(): """ return 'iprand' - +@doctest_refactor_print def iprand_all(): """Some ipython tests with fully random output. @@ -160,3 +161,4 @@ def iprand_all(): return 'iprand_all' + diff --git a/IPython/testing/plugin/test_ipdoctest.py b/IPython/testing/plugin/test_ipdoctest.py index 6d04b92..a7add7d 100644 --- a/IPython/testing/plugin/test_ipdoctest.py +++ b/IPython/testing/plugin/test_ipdoctest.py @@ -6,7 +6,9 @@ a doctest) and which have no test functionality of their own, should be called empty function call is counted as a test, which just inflates tests numbers artificially). """ +from IPython.utils.py3compat import doctest_refactor_print +@doctest_refactor_print def doctest_simple(): """ipdoctest must handle simple inputs @@ -17,17 +19,20 @@ def doctest_simple(): 1 """ - +@doctest_refactor_print def doctest_multiline1(): """The ipdoctest machinery must handle multiline examples gracefully. - In [2]: for i in range(10): - ...: print i, + In [2]: for i in range(4): + ...: print i ...: - 0 1 2 3 4 5 6 7 8 9 + 0 + 1 + 2 + 3 """ - +@doctest_refactor_print def doctest_multiline2(): """Multiline examples that define functions and print output. diff --git a/IPython/testing/plugin/test_refs.py b/IPython/testing/plugin/test_refs.py index 781519e..50d0857 100644 --- a/IPython/testing/plugin/test_refs.py +++ b/IPython/testing/plugin/test_refs.py @@ -42,5 +42,5 @@ def doctest_refs(): """DocTest reference holding issues when running scripts. In [32]: run show_refs.py - c referrers: [] + c referrers: [<... 'dict'>] """ diff --git a/IPython/testing/tests/test_ipunittest.py b/IPython/testing/tests/test_ipunittest.py index 25ee423..edd2564 100644 --- a/IPython/testing/tests/test_ipunittest.py +++ b/IPython/testing/tests/test_ipunittest.py @@ -46,11 +46,13 @@ Authors #----------------------------------------------------------------------------- from IPython.testing.ipunittest import ipdoctest, ipdocstring +from IPython.utils.py3compat import doctest_refactor_print #----------------------------------------------------------------------------- # Test classes and functions #----------------------------------------------------------------------------- @ipdoctest +@doctest_refactor_print def simple_dt(): """ >>> print 1+1 @@ -59,16 +61,20 @@ def simple_dt(): @ipdoctest +@doctest_refactor_print def ipdt_flush(): """ In [20]: print 1 1 -In [26]: for i in range(10): - ....: print i, +In [26]: for i in range(4): + ....: print i ....: ....: -0 1 2 3 4 5 6 7 8 9 +0 +1 +2 +3 In [27]: 3+4 Out[27]: 7 @@ -76,16 +82,20 @@ Out[27]: 7 @ipdoctest +@doctest_refactor_print def ipdt_indented_test(): """ In [20]: print 1 1 - In [26]: for i in range(10): - ....: print i, + In [26]: for i in range(4): + ....: print i ....: ....: - 0 1 2 3 4 5 6 7 8 9 + 0 + 1 + 2 + 3 In [27]: 3+4 Out[27]: 7 @@ -100,21 +110,26 @@ class Foo(object): """ @ipdocstring + @doctest_refactor_print def ipdt_method(self): """ In [20]: print 1 1 - In [26]: for i in range(10): - ....: print i, + In [26]: for i in range(4): + ....: print i ....: ....: - 0 1 2 3 4 5 6 7 8 9 + 0 + 1 + 2 + 3 In [27]: 3+4 Out[27]: 7 """ + @doctest_refactor_print def normaldt_method(self): """ >>> print 1+1