summaryrefslogtreecommitdiff
path: root/lab
diff options
context:
space:
mode:
authorcclauss <cclauss@bluewin.ch>2018-06-25 11:20:03 +0200
committercclauss <cclauss@bluewin.ch>2018-06-25 11:20:03 +0200
commit14b311b7783be3bc2823f17e003d8b9c6efbd3ab (patch)
treedb30566c76d0fa46f9c67c4ec9f633af2c7777db /lab
parenta0f99e8ab4161dfb23c08defdc581e8e77f9b7ff (diff)
downloadpython-coveragepy-git-14b311b7783be3bc2823f17e003d8b9c6efbd3ab.tar.gz
print() is a function in Python 3
Diffstat (limited to 'lab')
-rw-r--r--lab/branches.py26
-rw-r--r--lab/run_trace.py4
-rw-r--r--lab/show_platform.py2
3 files changed, 16 insertions, 16 deletions
diff --git a/lab/branches.py b/lab/branches.py
index 5a35f1bd..c2b838dd 100644
--- a/lab/branches.py
+++ b/lab/branches.py
@@ -13,11 +13,11 @@ def my_function(x):
i = 0
while True:
- print "In while True"
+ print("In while True")
if i > 0:
break
i += 1
- print "Left the True loop"
+ print("Left the True loop")
# Notice that "while 1" also has this problem. Even though the compiler
# knows there's no computation at the top of the loop, it's still expressed
@@ -25,11 +25,11 @@ def my_function(x):
i = 0
while 1:
- print "In while 1"
+ print("In while 1")
if i > 0:
break
i += 1
- print "Left the 1 loop"
+ print("Left the 1 loop")
# Coverage.py lets developers exclude lines that they know will not be
# executed. So far, the branch coverage doesn't use all that information
@@ -40,9 +40,9 @@ def my_function(x):
if x < 1000:
# This branch is always taken
- print "x is reasonable"
+ print("x is reasonable")
else: # pragma: nocover
- print "this never happens"
+ print("this never happens")
# try-except structures are complex branches. An except clause with a
# type is a three-way branch: there could be no exception, there could be
@@ -57,9 +57,9 @@ def my_function(x):
if y % 2:
raise ValueError("y is odd!")
except ValueError:
- print "y must have been odd"
- print "done with y"
- print "done with 1, 2"
+ print("y must have been odd")
+ print("done with y")
+ print("done with 1, 2")
# Another except clause, but this time all three cases are executed. No
# partial lines are shown:
@@ -71,11 +71,11 @@ def my_function(x):
if y == 0:
raise Exception("zero!")
except ValueError:
- print "y must have been odd"
+ print("y must have been odd")
except:
- print "y is something else"
- print "done with y"
- print "done with 0, 1, 2"
+ print("y is something else")
+ print("done with y")
+ print("done with 0, 1, 2")
my_function(1)
diff --git a/lab/run_trace.py b/lab/run_trace.py
index ea9d9bb4..27c24a1d 100644
--- a/lab/run_trace.py
+++ b/lab/run_trace.py
@@ -14,13 +14,13 @@ def trace(frame, event, arg):
# This can happen when Python is shutting down.
return None
- print "%s%s %s %d @%d" % (
+ print("%s%s %s %d @%d" % (
" " * nest,
event,
os.path.basename(frame.f_code.co_filename),
frame.f_lineno,
frame.f_lasti,
- )
+ ))
if event == 'call':
nest += 1
diff --git a/lab/show_platform.py b/lab/show_platform.py
index 76122d58..e4f4dc2a 100644
--- a/lab/show_platform.py
+++ b/lab/show_platform.py
@@ -13,4 +13,4 @@ for n in dir(platform):
n += "()"
except:
continue
- print "%30s: %r" % (n, v)
+ print("%30s: %r" % (n, v))