Skip to content

Commit

Permalink
[svn r4492] make some non-public source files Py3 compliant (patch by…
Browse files Browse the repository at this point in the history
… Arfrever Frehtes Taifersar Arahesis)

--HG--
branch : trunk
  • Loading branch information
scoder committed Nov 23, 2010
1 parent 88706da commit 8f99c4b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
56 changes: 28 additions & 28 deletions src/local_doctest.py
Expand Up @@ -369,9 +369,9 @@ def trace_dispatch(self, *args):
# [XX] Normalize with respect to os.path.pardir?
def _module_relative_path(module, path):
if not inspect.ismodule(module):
raise TypeError, 'Expected a module: %r' % module
raise TypeError('Expected a module: %r' % module)
if path.startswith('/'):
raise ValueError, 'Module-relative files may not have absolute paths'
raise ValueError('Module-relative files may not have absolute paths')

# Find the base directory for the path.
if hasattr(module, '__file__'):
Expand Down Expand Up @@ -897,7 +897,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
add them to `tests`.
"""
if self._verbose:
print 'Finding tests in %s' % name
print('Finding tests in %s' % name)

# If we've already processed this object, then ignore it.
if id(obj) in seen:
Expand Down Expand Up @@ -1059,7 +1059,7 @@ class DocTestRunner:
>>> tests = DocTestFinder().find(_TestClass)
>>> runner = DocTestRunner(verbose=False)
>>> for test in tests:
... print runner.run(test)
... print(runner.run(test))
(0, 2)
(0, 1)
(0, 2)
Expand Down Expand Up @@ -1252,8 +1252,8 @@ def __run(self, test, compileflags, out):
# keyboard interrupts.)
try:
# Don't blink! This is where the user's code gets run.
exec compile(example.source, filename, "single",
compileflags, 1) in test.globs
exec(compile(example.source, filename, "single",
compileflags, 1), test.globs)
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
Expand Down Expand Up @@ -1427,28 +1427,28 @@ def summarize(self, verbose=None):
failed.append(x)
if verbose:
if notests:
print len(notests), "items had no tests:"
print("%s items had no tests:" % len(notests))
notests.sort()
for thing in notests:
print " ", thing
print(" %s" % thing)
if passed:
print len(passed), "items passed all tests:"
print("%s items passed all tests:" % len(passed))
passed.sort()
for thing, count in passed:
print " %3d tests in %s" % (count, thing)
print(" %3d tests in %s" % (count, thing))
if failed:
print self.DIVIDER
print len(failed), "items had failures:"
print(self.DIVIDER)
print("%s items had failures:" % len(failed))
failed.sort()
for thing, (f, t) in failed:
print " %3d of %3d in %s" % (f, t, thing)
print(" %3d of %3d in %s" % (f, t, thing))
if verbose:
print totalt, "tests in", len(self._name2ft), "items."
print totalt - totalf, "passed and", totalf, "failed."
print("%s tests in %s items." % (totalt, len(self._name2ft)))
print("%s passed and %s failed." % (totalt - totalf, totalf))
if totalf:
print "***Test Failed***", totalf, "failures."
print("***Test Failed*** %s failures." % totalf)
elif verbose:
print "Test passed."
print("Test passed.")
return totalf, totalt

#/////////////////////////////////////////////////////////////////
Expand All @@ -1458,8 +1458,8 @@ def merge(self, other):
d = self._name2ft
for name, (f, t) in other._name2ft.items():
if name in d:
print "*** DocTestRunner.merge: '" + name + "' in both" \
" testers; summing outcomes."
print("*** DocTestRunner.merge: '" + name + "' in both"
" testers; summing outcomes.")
f2, t2 = d[name]
f = f + f2
t = t + t2
Expand Down Expand Up @@ -2037,10 +2037,10 @@ def __init__(self, mod=None, globs=None, verbose=None,
def runstring(self, s, name):
test = DocTestParser().get_doctest(s, self.globs, name, None, None)
if self.verbose:
print "Running string", name
print("Running string %s" % name)
(f,t) = self.testrunner.run(test)
if self.verbose:
print f, "of", t, "examples failed in string", name
print("%s of %s examples failed in string %s" % (f, t, name))
return (f,t)

def rundoc(self, object, name=None, module=None):
Expand Down Expand Up @@ -2487,7 +2487,7 @@ def script_from_examples(s):
... Ho hum
... '''
>>> print script_from_examples(text)
>>> print(script_from_examples(text))
# Here are examples of simple math.
#
# Python has super accurate integer addition
Expand Down Expand Up @@ -2578,7 +2578,7 @@ def debug_script(src, pm=False, globs=None):
try:
execfile(srcfilename, globs, globs)
except:
print sys.exc_info()[1]
print(sys.exc_info()[1])
pdb.post_mortem(sys.exc_info()[2])
else:
# Note that %r is vital here. '%s' instead can, e.g., cause
Expand Down Expand Up @@ -2620,7 +2620,7 @@ def __init__(self, val):
"""val -> _TestClass object with associated value val.
>>> t = _TestClass(123)
>>> print t.get()
>>> print(t.get())
123
"""

Expand All @@ -2640,7 +2640,7 @@ def get(self):
"""get() -> return TestClass's associated value.
>>> x = _TestClass(-42)
>>> print x.get()
>>> print(x.get())
-42
"""

Expand Down Expand Up @@ -2672,7 +2672,7 @@ def get(self):

"blank lines": r"""
Blank lines can be marked with <BLANKLINE>:
>>> print 'foo\n\nbar\n'
>>> print('foo\n\nbar\n')
foo
<BLANKLINE>
bar
Expand All @@ -2682,14 +2682,14 @@ def get(self):
"ellipsis": r"""
If the ellipsis flag is used, then '...' can be used to
elide substrings in the desired output:
>>> print range(1000) #doctest: +ELLIPSIS
>>> print(range(1000)) #doctest: +ELLIPSIS
[0, 1, 2, ..., 999]
""",

"whitespace normalization": r"""
If the whitespace normalization flag is used, then
differences in whitespace are ignored.
>>> print range(30) #doctest: +NORMALIZE_WHITESPACE
>>> print(range(30)) #doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29]
Expand Down
2 changes: 1 addition & 1 deletion src/lxml/html/_diffcommand.py
Expand Up @@ -82,6 +82,6 @@ def split_body(html):
return pre, html, post

def annotate(options, args):
print "Not yet implemented"
print("Not yet implemented")
sys.exit(1)

6 changes: 3 additions & 3 deletions src/lxml/html/tests/transform_feedparser_data.py
Expand Up @@ -88,10 +88,10 @@ def translate_file(filename):
try:
output = serialize_content(parse_content(c))
except:
print 'Bad data in %s:' % filename
print c
print('Bad data in %s:' % filename)
print(c)
traceback.print_exc()
print '-'*60
print('-'*60)
return
new = os.path.splitext(filename)[0] + '.data'
f = open(new, 'wb')
Expand Down
2 changes: 1 addition & 1 deletion src/lxml/tests/test_errors.py
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import unittest, doctest

# These tests check that error handling in the Pyrex code is
Expand Down

0 comments on commit 8f99c4b

Please sign in to comment.