Skip to content

Commit 7be5d8a

Browse files
committed
Improve test cases
1 parent eb5cb3b commit 7be5d8a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Lib/idlelib/idle_test/test_warning.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class TestDeprecatedHelp(unittest.TestCase):
8181
@deprecated("Test")
8282
class A:
8383
pass
84+
a = A()
8485
"""
8586
CODE_SUBCLASS = r"""
8687
from warnings import deprecated
@@ -100,12 +101,15 @@ def tearDown(self):
100101
del sys.modules["testmodule"]
101102

102103
def _get_help_output(self, code):
103-
exec(code, self.module.__dict__)
104-
sys.modules["testmodule"] = self.module
104+
with self.assertWarns(DeprecationWarning) as cm:
105+
exec(code, self.module.__dict__)
106+
sys.modules["testmodule"] = self.module
105107

106-
f = io.StringIO()
107-
with redirect_stdout(f):
108-
help(self.module)
108+
f = io.StringIO()
109+
with redirect_stdout(f):
110+
help(self.module)
111+
112+
self.assertEqual(str(cm.warning), "Test")
109113
return f.getvalue()
110114

111115
def test_help_output(self):

0 commit comments

Comments
 (0)