mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
StringIo is now always used as part of the io library
This commit is contained in:
@@ -118,12 +118,6 @@ Usage::
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# StringIO (Python 2.5 has no io module), so use io only for py3k
|
|
||||||
try:
|
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
# hasattr function used because python
|
# hasattr function used because python
|
||||||
if is_py3:
|
if is_py3:
|
||||||
hasattr = hasattr
|
hasattr = hasattr
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
import string
|
import string
|
||||||
import re
|
import re
|
||||||
from jedi._compatibility import StringIO
|
from io import StringIO
|
||||||
from token import *
|
from token import *
|
||||||
import collections
|
import collections
|
||||||
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
|
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
|
||||||
|
|||||||
16
test/run.py
16
test/run.py
@@ -99,10 +99,11 @@ Tests look like this::
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
|
from io import StringIO
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
from functools import reduce
|
from jedi._compatibility import unicode, is_py3
|
||||||
from jedi._compatibility import unicode, StringIO, is_py3
|
|
||||||
|
|
||||||
|
|
||||||
TEST_COMPLETIONS = 0
|
TEST_COMPLETIONS = 0
|
||||||
@@ -215,10 +216,7 @@ def collect_file_tests(lines, lines_to_execute):
|
|||||||
start = None
|
start = None
|
||||||
correct = None
|
correct = None
|
||||||
test_type = None
|
test_type = None
|
||||||
for line_nr, line in enumerate(lines):
|
for line_nr, line in enumerate(lines, 1):
|
||||||
line_nr += 1 # py2.5 doesn't know about the additional enumerate param
|
|
||||||
if not is_py3:
|
|
||||||
line = unicode(line, 'UTF-8')
|
|
||||||
if correct:
|
if correct:
|
||||||
r = re.match('^(\d+)\s*(.*)$', correct)
|
r = re.match('^(\d+)\s*(.*)$', correct)
|
||||||
if r:
|
if r:
|
||||||
@@ -268,6 +266,8 @@ def collect_dir_tests(base_dir, test_files, check_thirdparty=False):
|
|||||||
|
|
||||||
path = os.path.join(base_dir, f_name)
|
path = os.path.join(base_dir, f_name)
|
||||||
source = open(path).read()
|
source = open(path).read()
|
||||||
|
if not is_py3:
|
||||||
|
source = unicode(source, 'UTF-8')
|
||||||
for case in collect_file_tests(StringIO(source),
|
for case in collect_file_tests(StringIO(source),
|
||||||
lines_to_execute):
|
lines_to_execute):
|
||||||
case.path = path
|
case.path = path
|
||||||
@@ -373,8 +373,4 @@ if __name__ == '__main__':
|
|||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
exit_code = 1 if tests_fail else 0
|
exit_code = 1 if tests_fail else 0
|
||||||
if sys.hexversion < 0x02060000 and tests_fail <= 9:
|
|
||||||
# Python 2.5 has major incompabillities (e.g. no property.setter),
|
|
||||||
# therefore it is not possible to pass all tests.
|
|
||||||
exit_code = 0
|
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|||||||
Reference in New Issue
Block a user