Show More
@@ -27,8 +27,6 Authors: | |||
|
27 | 27 | import abc |
|
28 | 28 | import sys |
|
29 | 29 | import warnings |
|
30 | # We must use StringIO, as cStringIO doesn't handle unicode properly. | |
|
31 | from io import StringIO | |
|
32 | 30 | |
|
33 | 31 | # Our own imports |
|
34 | 32 | from IPython.config.configurable import Configurable |
@@ -36,7 +34,12 from IPython.lib import pretty | |||
|
36 | 34 | from IPython.utils.traitlets import ( |
|
37 | 35 | Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List, |
|
38 | 36 | ) |
|
39 | from IPython.utils.py3compat import unicode_to_str, with_metaclass | |
|
37 | from IPython.utils.py3compat import unicode_to_str, with_metaclass, PY3 | |
|
38 | ||
|
39 | if PY3: | |
|
40 | from io import StringIO | |
|
41 | else: | |
|
42 | from StringIO import StringIO | |
|
40 | 43 | |
|
41 | 44 | |
|
42 | 45 | #----------------------------------------------------------------------------- |
@@ -1,14 +1,18 | |||
|
1 | 1 | import abc |
|
2 | 2 | import functools |
|
3 | 3 | import re |
|
4 | from io import StringIO | |
|
5 | 4 | |
|
6 | 5 | from IPython.core.splitinput import LineInfo |
|
7 | 6 | from IPython.utils import tokenize2 |
|
8 | 7 | from IPython.utils.openpy import cookie_comment_re |
|
9 | from IPython.utils.py3compat import with_metaclass | |
|
8 | from IPython.utils.py3compat import with_metaclass, PY3 | |
|
10 | 9 | from IPython.utils.tokenize2 import generate_tokens, untokenize, TokenError |
|
11 | 10 | |
|
11 | if PY3: | |
|
12 | from io import StringIO | |
|
13 | else: | |
|
14 | from StringIO import StringIO | |
|
15 | ||
|
12 | 16 | #----------------------------------------------------------------------------- |
|
13 | 17 | # Globals |
|
14 | 18 | #----------------------------------------------------------------------------- |
@@ -20,7 +20,6 import bdb | |||
|
20 | 20 | import os |
|
21 | 21 | import sys |
|
22 | 22 | import time |
|
23 | from io import StringIO | |
|
24 | 23 | |
|
25 | 24 | # cProfile was added in Python2.5 |
|
26 | 25 | try: |
@@ -43,7 +42,7 from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, | |||
|
43 | 42 | line_cell_magic, on_off, needs_local_scope) |
|
44 | 43 | from IPython.testing.skipdoctest import skip_doctest |
|
45 | 44 | from IPython.utils import py3compat |
|
46 | from IPython.utils.py3compat import builtin_mod, iteritems | |
|
45 | from IPython.utils.py3compat import builtin_mod, iteritems, PY3 | |
|
47 | 46 | from IPython.utils.contexts import preserve_keys |
|
48 | 47 | from IPython.utils.io import capture_output |
|
49 | 48 | from IPython.utils.ipstruct import Struct |
@@ -52,6 +51,10 from IPython.utils.path import get_py_filename, unquote_filename, shellglob | |||
|
52 | 51 | from IPython.utils.timing import clock, clock2 |
|
53 | 52 | from IPython.utils.warn import warn, error |
|
54 | 53 | |
|
54 | if PY3: | |
|
55 | from io import StringIO | |
|
56 | else: | |
|
57 | from StringIO import StringIO | |
|
55 | 58 | |
|
56 | 59 | #----------------------------------------------------------------------------- |
|
57 | 60 | # Magic implementation classes |
@@ -28,7 +28,6 import sys | |||
|
28 | 28 | import tempfile |
|
29 | 29 | import unittest |
|
30 | 30 | from os.path import join |
|
31 | from io import StringIO | |
|
32 | 31 | |
|
33 | 32 | # third-party |
|
34 | 33 | import nose.tools as nt |
@@ -37,7 +36,12 import nose.tools as nt | |||
|
37 | 36 | from IPython.testing.decorators import skipif, skip_win32, onlyif_unicode_paths |
|
38 | 37 | from IPython.testing import tools as tt |
|
39 | 38 | from IPython.utils import io |
|
40 | from IPython.utils.py3compat import unicode_type | |
|
39 | from IPython.utils.py3compat import unicode_type, PY3 | |
|
40 | ||
|
41 | if PY3: | |
|
42 | from io import StringIO | |
|
43 | else: | |
|
44 | from StringIO import StringIO | |
|
41 | 45 | |
|
42 | 46 | #----------------------------------------------------------------------------- |
|
43 | 47 | # Globals |
@@ -12,7 +12,6 from __future__ import absolute_import | |||
|
12 | 12 | import io |
|
13 | 13 | import os |
|
14 | 14 | import sys |
|
15 | from io import StringIO | |
|
16 | 15 | from unittest import TestCase |
|
17 | 16 | |
|
18 | 17 | try: |
@@ -38,6 +37,11 from IPython.utils.io import capture_output | |||
|
38 | 37 | from IPython.utils.tempdir import TemporaryDirectory |
|
39 | 38 | from IPython.utils.process import find_cmd |
|
40 | 39 | |
|
40 | if py3compat.PY3: | |
|
41 | from io import StringIO | |
|
42 | else: | |
|
43 | from StringIO import StringIO | |
|
44 | ||
|
41 | 45 | #----------------------------------------------------------------------------- |
|
42 | 46 | # Test functions begin |
|
43 | 47 | #----------------------------------------------------------------------------- |
@@ -18,13 +18,18 import tempfile | |||
|
18 | 18 | import shutil |
|
19 | 19 | import random |
|
20 | 20 | import time |
|
21 | from io import StringIO | |
|
22 | 21 | |
|
23 | 22 | import nose.tools as nt |
|
24 | 23 | import IPython.testing.tools as tt |
|
25 | 24 | |
|
26 | 25 | from IPython.extensions.autoreload import AutoreloadMagics |
|
27 | 26 | from IPython.core.hooks import TryNext |
|
27 | from IPython.utils.py3compat import PY3 | |
|
28 | ||
|
29 | if PY3: | |
|
30 | from io import StringIO | |
|
31 | else: | |
|
32 | from StringIO import StringIO | |
|
28 | 33 | |
|
29 | 34 | #----------------------------------------------------------------------------- |
|
30 | 35 | # Test fixture |
@@ -1,11 +1,15 | |||
|
1 | from io import StringIO | |
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | from IPython.testing.decorators import skip_without |
|
5 | 3 | from IPython.extensions import rmagic |
|
4 | from IPython.utils.py3compat import PY3 | |
|
6 | 5 | from rpy2 import rinterface |
|
7 | 6 | import nose.tools as nt |
|
8 | 7 | |
|
8 | if PY3: | |
|
9 | from io import StringIO | |
|
10 | else: | |
|
11 | from StringIO import StringIO | |
|
12 | ||
|
9 | 13 | ip = get_ipython() |
|
10 | 14 | ip.magic('load_ext rmagic') |
|
11 | 15 |
@@ -11,7 +11,6 | |||
|
11 | 11 | from __future__ import print_function |
|
12 | 12 | |
|
13 | 13 | # Standard library imports |
|
14 | from io import StringIO | |
|
15 | 14 | import sys |
|
16 | 15 | import unittest |
|
17 | 16 | |
@@ -23,6 +22,11 from IPython.testing.decorators import skipif_not_matplotlib | |||
|
23 | 22 | from IPython.utils.io import capture_output |
|
24 | 23 | from IPython.utils import py3compat |
|
25 | 24 | |
|
25 | if py3compat.PY3: | |
|
26 | from io import StringIO | |
|
27 | else: | |
|
28 | from StringIO import StringIO | |
|
29 | ||
|
26 | 30 | #----------------------------------------------------------------------------- |
|
27 | 31 | # Test case |
|
28 | 32 | #----------------------------------------------------------------------------- |
@@ -109,9 +109,15 import sys | |||
|
109 | 109 | import types |
|
110 | 110 | import re |
|
111 | 111 | import datetime |
|
112 | from io import StringIO | |
|
113 | 112 | from collections import deque |
|
114 | 113 | |
|
114 | from IPython.utils.py3compat import PY3 | |
|
115 | ||
|
116 | if PY3: | |
|
117 | from io import StringIO | |
|
118 | else: | |
|
119 | from StringIO import StringIO | |
|
120 | ||
|
115 | 121 | |
|
116 | 122 | __all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter', |
|
117 | 123 | 'for_type', 'for_type_by_name'] |
@@ -8,19 +8,23 from __future__ import print_function | |||
|
8 | 8 | VERBOSE = True |
|
9 | 9 | |
|
10 | 10 | # stdlib imports |
|
11 | import io | |
|
12 | 11 | import sys |
|
13 | 12 | import unittest |
|
14 | 13 | |
|
15 | 14 | # IPython imports |
|
16 | 15 | from IPython.lib import irunner |
|
17 | from IPython.utils.py3compat import doctest_refactor_print | |
|
16 | from IPython.utils.py3compat import doctest_refactor_print, PY3 | |
|
17 | ||
|
18 | if PY3: | |
|
19 | from io import StringIO | |
|
20 | else: | |
|
21 | from StringIO import StringIO | |
|
18 | 22 | |
|
19 | 23 | # Testing code begins |
|
20 | 24 | class RunnerTestCase(unittest.TestCase): |
|
21 | 25 | |
|
22 | 26 | def setUp(self): |
|
23 |
self.out = |
|
|
27 | self.out = StringIO() | |
|
24 | 28 | #self.out = sys.stdout |
|
25 | 29 | |
|
26 | 30 | def _test_runner(self,runner,source,output): |
@@ -7,7 +7,6 from __future__ import print_function | |||
|
7 | 7 | VERBOSE = True |
|
8 | 8 | |
|
9 | 9 | # stdlib imports |
|
10 | import io | |
|
11 | 10 | import sys |
|
12 | 11 | import unittest |
|
13 | 12 | import re |
@@ -15,6 +14,12 import re | |||
|
15 | 14 | # IPython imports |
|
16 | 15 | from IPython.lib import irunner |
|
17 | 16 | from IPython.testing import decorators |
|
17 | from IPython.utils.py3compat import PY3 | |
|
18 | ||
|
19 | if PY3: | |
|
20 | from io import StringIO | |
|
21 | else: | |
|
22 | from StringIO import StringIO | |
|
18 | 23 | |
|
19 | 24 | def pylab_not_importable(): |
|
20 | 25 | """Test if importing pylab fails. (For example, when having no display)""" |
@@ -28,7 +33,7 def pylab_not_importable(): | |||
|
28 | 33 | class RunnerTestCase(unittest.TestCase): |
|
29 | 34 | |
|
30 | 35 | def setUp(self): |
|
31 |
self.out = |
|
|
36 | self.out = StringIO() | |
|
32 | 37 | #self.out = sys.stdout |
|
33 | 38 | |
|
34 | 39 | def _test_runner(self,runner,source,output): |
@@ -15,10 +15,15 Module with tests for debug | |||
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | 17 | import sys |
|
18 | from io import StringIO | |
|
19 | 18 | |
|
20 | 19 | from ...tests.base import TestsBase |
|
21 | 20 | from ..debug import DebugWriter |
|
21 | from IPython.utils.py3compat import PY3 | |
|
22 | ||
|
23 | if PY3: | |
|
24 | from io import StringIO | |
|
25 | else: | |
|
26 | from StringIO import StringIO | |
|
22 | 27 | |
|
23 | 28 | |
|
24 | 29 | #----------------------------------------------------------------------------- |
@@ -16,10 +16,15 Module with tests for files | |||
|
16 | 16 | |
|
17 | 17 | import sys |
|
18 | 18 | import os |
|
19 | from io import StringIO | |
|
20 | 19 | |
|
21 | 20 | from ...tests.base import TestsBase |
|
22 | 21 | from ..files import FilesWriter |
|
22 | from IPython.utils.py3compat import PY3 | |
|
23 | ||
|
24 | if PY3: | |
|
25 | from io import StringIO | |
|
26 | else: | |
|
27 | from StringIO import StringIO | |
|
23 | 28 | |
|
24 | 29 | |
|
25 | 30 | #----------------------------------------------------------------------------- |
@@ -15,10 +15,15 Module with tests for stdout | |||
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | 17 | import sys |
|
18 | from io import StringIO | |
|
19 | 18 | |
|
20 | 19 | from ...tests.base import TestsBase |
|
21 | 20 | from ..stdout import StdoutWriter |
|
21 | from IPython.utils.py3compat import PY3 | |
|
22 | ||
|
23 | if PY3: | |
|
24 | from io import StringIO | |
|
25 | else: | |
|
26 | from StringIO import StringIO | |
|
22 | 27 | |
|
23 | 28 | |
|
24 | 29 | #----------------------------------------------------------------------------- |
@@ -16,7 +16,6 from __future__ import print_function | |||
|
16 | 16 | import sys |
|
17 | 17 | import tempfile |
|
18 | 18 | import time |
|
19 | from io import StringIO | |
|
20 | 19 | |
|
21 | 20 | from nose import SkipTest |
|
22 | 21 |
@@ -58,7 +58,6 from __future__ import print_function | |||
|
58 | 58 | #----------------------------------------------------------------------------- |
|
59 | 59 | |
|
60 | 60 | # Stdlib |
|
61 | import io | |
|
62 | 61 | import os |
|
63 | 62 | import re |
|
64 | 63 | import sys |
@@ -84,6 +83,12 matplotlib.use('Agg') | |||
|
84 | 83 | from IPython import Config, InteractiveShell |
|
85 | 84 | from IPython.core.profiledir import ProfileDir |
|
86 | 85 | from IPython.utils import io |
|
86 | from IPython.utils.py3compat import PY3 | |
|
87 | ||
|
88 | if PY3: | |
|
89 | from io import StringIO | |
|
90 | else: | |
|
91 | from StringIO import StringIO | |
|
87 | 92 | |
|
88 | 93 | #----------------------------------------------------------------------------- |
|
89 | 94 | # Globals |
@@ -193,7 +198,7 class EmbeddedSphinxShell(object): | |||
|
193 | 198 | |
|
194 | 199 | def __init__(self): |
|
195 | 200 | |
|
196 |
self.cout = |
|
|
201 | self.cout = StringIO() | |
|
197 | 202 | |
|
198 | 203 | |
|
199 | 204 | # Create config object for IPython |
@@ -29,7 +29,6 import traceback | |||
|
29 | 29 | import unittest |
|
30 | 30 | |
|
31 | 31 | from inspect import getmodule |
|
32 | from io import StringIO | |
|
33 | 32 | |
|
34 | 33 | # We are overriding the default doctest runner, so we need to import a few |
|
35 | 34 | # things from doctest directly |
@@ -46,7 +45,12 from nose.plugins import doctests, Plugin | |||
|
46 | 45 | from nose.util import anyp, getpackage, test_address, resolve_name, tolist |
|
47 | 46 | |
|
48 | 47 | # Our own imports |
|
49 | from IPython.utils.py3compat import builtin_mod | |
|
48 | from IPython.utils.py3compat import builtin_mod, PY3 | |
|
49 | ||
|
50 | if PY3: | |
|
51 | from io import StringIO | |
|
52 | else: | |
|
53 | from StringIO import StringIO | |
|
50 | 54 | |
|
51 | 55 | #----------------------------------------------------------------------------- |
|
52 | 56 | # Module globals and other constants |
@@ -38,7 +38,6 _scheme_default = 'Linux' | |||
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | # Imports |
|
41 | import io | |
|
42 | 41 | import keyword |
|
43 | 42 | import os |
|
44 | 43 | import sys |
@@ -53,6 +52,12 except AttributeError: | |||
|
53 | 52 | generate_tokens = tokenize._tokenize |
|
54 | 53 | |
|
55 | 54 | from IPython.utils.coloransi import * |
|
55 | from IPython.utils.py3compat import PY3 | |
|
56 | ||
|
57 | if PY3: | |
|
58 | from io import StringIO | |
|
59 | else: | |
|
60 | from StringIO import StringIO | |
|
56 | 61 | |
|
57 | 62 | ############################################################################# |
|
58 | 63 | ### Python Source Parser (does Hilighting) |
@@ -143,13 +148,13 class Parser: | |||
|
143 | 148 | |
|
144 | 149 | string_output = 0 |
|
145 | 150 | if out == 'str' or self.out == 'str' or \ |
|
146 |
isinstance(self.out, |
|
|
151 | isinstance(self.out,StringIO): | |
|
147 | 152 | # XXX - I don't really like this state handling logic, but at this |
|
148 | 153 | # point I don't want to make major changes, so adding the |
|
149 | 154 | # isinstance() check is the simplest I can do to ensure correct |
|
150 | 155 | # behavior. |
|
151 | 156 | out_old = self.out |
|
152 |
self.out = |
|
|
157 | self.out = StringIO() | |
|
153 | 158 | string_output = 1 |
|
154 | 159 | elif out is not None: |
|
155 | 160 | self.out = out |
@@ -183,7 +188,7 class Parser: | |||
|
183 | 188 | |
|
184 | 189 | # parse the source and write it |
|
185 | 190 | self.pos = 0 |
|
186 |
text = |
|
|
191 | text = StringIO(self.raw) | |
|
187 | 192 | |
|
188 | 193 | error = False |
|
189 | 194 | try: |
@@ -16,7 +16,13 from __future__ import print_function, absolute_import | |||
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | 18 | import sys |
|
19 | ||
|
20 | from IPython.utils.py3compat import PY3 | |
|
21 | ||
|
22 | if PY3: | |
|
19 | 23 | from io import StringIO |
|
24 | else: | |
|
25 | from StringIO import StringIO | |
|
20 | 26 | |
|
21 | 27 | #----------------------------------------------------------------------------- |
|
22 | 28 | # Classes and functions |
@@ -15,14 +15,18 from __future__ import print_function | |||
|
15 | 15 | |
|
16 | 16 | import sys |
|
17 | 17 | |
|
18 | from io import StringIO | |
|
19 | 18 | from subprocess import Popen, PIPE |
|
20 | 19 | import unittest |
|
21 | 20 | |
|
22 | 21 | import nose.tools as nt |
|
23 | 22 | |
|
24 | 23 | from IPython.utils.io import Tee, capture_output |
|
25 | from IPython.utils.py3compat import doctest_refactor_print | |
|
24 | from IPython.utils.py3compat import doctest_refactor_print, PY3 | |
|
25 | ||
|
26 | if PY3: | |
|
27 | from io import StringIO | |
|
28 | else: | |
|
29 | from StringIO import StringIO | |
|
26 | 30 | |
|
27 | 31 | #----------------------------------------------------------------------------- |
|
28 | 32 | # Tests |
General Comments 0
You need to be logged in to leave comments.
Login now