most tests pass for python 3

This commit is contained in:
David Halter
2012-05-20 00:25:30 +02:00
parent c95510cf50
commit 8d523db9d9
4 changed files with 13 additions and 5 deletions
+7
View File
@@ -50,6 +50,13 @@ except AttributeError:
else: else:
property = property property = property
# unicode function
try:
unicode = unicode
except NameError:
def unicode(s):
return s.decode("utf-8")
# Borrowed from Ned Batchelder # Borrowed from Ned Batchelder
if sys.hexversion > 0x03000000: if sys.hexversion > 0x03000000:
def exec_function(source, global_map): def exec_function(source, global_map):
+1 -1
View File
@@ -3,7 +3,7 @@
import functions import functions
functions.debug.debug_function = functions.debug.print_to_stdout functions.debug.debug_function = functions.debug.print_to_stdout
#functions.debug.ignored_modules = ['parsing', 'builtin'] functions.debug.ignored_modules = ['parsing', 'builtin']
#functions.debug.ignored_modules = ['parsing', 'builtin', 'evaluate', 'modules'] #functions.debug.ignored_modules = ['parsing', 'builtin', 'evaluate', 'modules']
functions.modules.builtin.module_find_path.insert(0, '.') functions.modules.builtin.module_find_path.insert(0, '.')
-1
View File
@@ -1276,7 +1276,6 @@ class PyFuzzyParser(object):
# check again for unindented stuff. this is true for syntax # check again for unindented stuff. this is true for syntax
# errors. only check for names, because thats relevant here. If # errors. only check for names, because thats relevant here. If
# some docstrings are not indented, I don't care. # some docstrings are not indented, I don't care.
print(self.scope.indent, self.scope)
while indent <= self.scope.indent \ while indent <= self.scope.indent \
and (token_type == tokenize.NAME or tok in ['(', '['])\ and (token_type == tokenize.NAME or tok in ['(', '['])\
and self.scope != self.top: and self.scope != self.top:
+5 -3
View File
@@ -2,12 +2,13 @@
import os import os
import sys import sys
import re import re
import StringIO from io import BytesIO
import traceback import traceback
os.chdir('../') os.chdir('../')
sys.path.append('.') sys.path.append('.')
import functions import functions
from _compatibility import unicode
#functions.set_debug_function(functions.debug.print_to_stdout) #functions.set_debug_function(functions.debug.print_to_stdout)
@@ -80,7 +81,8 @@ def completion_test(source):
fails = 0 fails = 0
tests = 0 tests = 0
correct = None correct = None
for line_nr, line in enumerate(StringIO.StringIO(source)): for line_nr, line in enumerate(BytesIO(source.encode())):
line = unicode(line)
line_nr += 1 line_nr += 1
if correct: if correct:
# if a list is wanted, use the completion test, otherwise the # if a list is wanted, use the completion test, otherwise the
@@ -95,7 +97,7 @@ def completion_test(source):
else: else:
try: try:
correct = re.search(r'(?:^|\s)#\?\s*([^\n]+)', line).group(1) correct = re.search(r'(?:^|\s)#\?\s*([^\n]+)', line).group(1)
except: except AttributeError:
correct = None correct = None
else: else:
# reset the test, if only one specific test is wanted # reset the test, if only one specific test is wanted