summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-20 13:59:46 +0000
committerGeorg Brandl <georg@python.org>2008-01-20 13:59:46 +0000
commit56112895d69131ee4f34d4e3e9406614313df57f (patch)
treeb57e176cd54df7984553c6337390ce1712fb2292 /Lib/test
parent92058d29334fcb4d01ae2ab7c165aba2ef6da2af (diff)
downloadcpython-git-56112895d69131ee4f34d4e3e9406614313df57f.tar.gz
#1648: add sys.gettrace() and sys.getprofile().
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_profilehooks.py17
-rw-r--r--Lib/test/test_trace.py14
2 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py
index 53f882a3fe..2eedfd92e9 100644
--- a/Lib/test/test_profilehooks.py
+++ b/Lib/test/test_profilehooks.py
@@ -4,6 +4,22 @@ import unittest
from test import test_support
+class TestGetProfile(unittest.TestCase):
+ def setUp(self):
+ sys.setprofile(None)
+
+ def tearDown(self):
+ sys.setprofile(None)
+
+ def test_empty(self):
+ assert sys.getprofile() == None
+
+ def test_setget(self):
+ def fn(*args):
+ pass
+
+ sys.setprofile(fn)
+ assert sys.getprofile() == fn
class HookWatcher:
def __init__(self):
@@ -359,6 +375,7 @@ def show_events(callable):
def test_main():
test_support.run_unittest(
+ TestGetProfile,
ProfileHookTestCase,
ProfileSimulatorTestCase
)
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 230f7bbd0e..144fc66dce 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -268,6 +268,20 @@ class TraceTestCase(unittest.TestCase):
self.compare_events(func.func_code.co_firstlineno,
tracer.events, func.events)
+ def set_and_retrieve_none(self):
+ sys.settrace(None)
+ assert sys.gettrace() is None
+
+ def set_and_retrieve_func(self):
+ def fn(*args):
+ pass
+
+ sys.settrace(fn)
+ try:
+ assert sys.gettrace() is fn
+ finally:
+ sys.settrace(None)
+
def test_01_basic(self):
self.run_test(basic)
def test_02_arigo(self):