#1648: add sys.gettrace() and sys.getprofile().
diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py
index 53f882a..2eedfd9 100644
--- a/Lib/test/test_profilehooks.py
+++ b/Lib/test/test_profilehooks.py
@@ -4,6 +4,22 @@
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 test_main():
test_support.run_unittest(
+ TestGetProfile,
ProfileHookTestCase,
ProfileSimulatorTestCase
)
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 230f7bb..144fc66 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -268,6 +268,20 @@
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):