diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-09-22 07:22:56 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-09-22 07:22:56 -0400 |
commit | ff9099051e0daff7b08035713eeca5696ab3217a (patch) | |
tree | 13a391e9010e9e0b99ff403ec2fd0252d460ab5a /test/farm/run/src | |
parent | e3c0b4b2c7d2a92344d30a25467a1e863bbb7d31 (diff) | |
download | python-coveragepy-git-ff9099051e0daff7b08035713eeca5696ab3217a.tar.gz |
The best way to get py3k support: same source runs on both, with some contortions.
Diffstat (limited to 'test/farm/run/src')
-rw-r--r-- | test/farm/run/src/chdir.py | 4 | ||||
-rw-r--r-- | test/farm/run/src/showtrace.py | 13 |
2 files changed, 10 insertions, 7 deletions
diff --git a/test/farm/run/src/chdir.py b/test/farm/run/src/chdir.py index 23c5afa8..d8287ed7 100644 --- a/test/farm/run/src/chdir.py +++ b/test/farm/run/src/chdir.py @@ -1,5 +1,5 @@ import os -print "Line One" +print("Line One") os.chdir("subdir") -print "Line Two" +print("Line Two") diff --git a/test/farm/run/src/showtrace.py b/test/farm/run/src/showtrace.py index 3708ac08..c3b4356c 100644 --- a/test/farm/run/src/showtrace.py +++ b/test/farm/run/src/showtrace.py @@ -3,13 +3,16 @@ import sys -# Print the argument as a label for the output. -print sys.argv[1], - # Show what the trace function is. If a C-based function is used, then f_trace # is None. trace_fn = sys._getframe(0).f_trace if trace_fn is None: - print "None" + trace_name = "None" else: - print trace_fn.im_class.__name__ + # Get the name of the tracer class. Py3k has a different way to get it. + try: + trace_name = trace_fn.im_class.__name__ + except AttributeError: + trace_name = trace_fn.__self__.__class__.__name__ + +print("%s %s" % (sys.argv[1], trace_name)) |