1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Replaced print statement by print function (forward compatibility syntax).

This commit is contained in:
Claude Paroz
2012-04-28 18:02:01 +02:00
parent fe43ad5707
commit 596cb9c7e2
61 changed files with 310 additions and 310 deletions

View File

@@ -878,7 +878,7 @@ class DocTestFinder:
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:
@@ -1034,7 +1034,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)
@@ -1406,28 +1406,28 @@ class DocTestRunner:
failed.append(x)
if verbose:
if notests:
print len(notests), "items had no tests:"
print("%d 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("%d 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("%d 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("%d tests in % d items" % (len(self._name2ft), totalt))
print("%d passed and %d failed." % (totalt - totalf, totalf))
if totalf:
print "***Test Failed***", totalf, "failures."
print("***Test Failed*** %d failures." % totalf)
elif verbose:
print "Test passed."
print("Test passed.")
return totalf, totalt
#/////////////////////////////////////////////////////////////////
@@ -1437,8 +1437,8 @@ class DocTestRunner:
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
@@ -2007,10 +2007,10 @@ class Tester:
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):
@@ -2442,7 +2442,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
@@ -2533,7 +2533,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
@@ -2575,7 +2575,7 @@ class _TestClass:
"""val -> _TestClass object with associated value val.
>>> t = _TestClass(123)
>>> print t.get()
>>> print(t.get())
123
"""
@@ -2595,7 +2595,7 @@ class _TestClass:
"""get() -> return TestClass's associated value.
>>> x = _TestClass(-42)
>>> print x.get()
>>> print(x.get())
-42
"""
@@ -2627,7 +2627,7 @@ __test__ = {"_TestClass": _TestClass,
"blank lines": r"""
Blank lines can be marked with <BLANKLINE>:
>>> print 'foo\n\nbar\n'
>>> print('foo\n\nbar\n')
foo
<BLANKLINE>
bar
@@ -2637,14 +2637,14 @@ __test__ = {"_TestClass": _TestClass,
"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]