MCPcopy Index your code
hub / github.com/python/cpython / test_trace_old

Method test_trace_old

Lib/test/test_tkinter/test_variables.py:115–180  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

113 self.assertTrue(v.side_effect)
114
115 def test_trace_old(self):
116 if tcl_version >= (9, 0):
117 self.skipTest('requires Tcl version < 9.0')
118 # Old interface
119 v = Variable(self.root)
120 vname = str(v)
121 trace = []
122 def read_tracer(*args):
123 trace.append(('read',) + args)
124 def write_tracer(*args):
125 trace.append(('write',) + args)
126 with self.assertWarns(DeprecationWarning) as cm:
127 cb1 = v.trace_variable('r', read_tracer)
128 self.assertEqual(cm.filename, __file__)
129 with self.assertWarns(DeprecationWarning):
130 cb2 = v.trace_variable('wu', write_tracer)
131 with self.assertWarns(DeprecationWarning) as cm:
132 self.assertEqual(sorted(v.trace_vinfo()), [('r', cb1), ('wu', cb2)])
133 self.assertEqual(cm.filename, __file__)
134 self.assertEqual(trace, [])
135
136 v.set('spam')
137 self.assertEqual(trace, [('write', vname, '', 'w')])
138
139 trace = []
140 v.get()
141 self.assertEqual(trace, [('read', vname, '', 'r')])
142
143 trace = []
144 with self.assertWarns(DeprecationWarning):
145 info = sorted(v.trace_vinfo())
146 with self.assertWarns(DeprecationWarning):
147 v.trace_vdelete('w', cb1) # Wrong mode
148 with self.assertWarns(DeprecationWarning):
149 self.assertEqual(sorted(v.trace_vinfo()), info)
150 with self.assertRaises(TclError):
151 with self.assertWarns(DeprecationWarning):
152 v.trace_vdelete('r', 'spam') # Wrong command name
153 with self.assertWarns(DeprecationWarning):
154 self.assertEqual(sorted(v.trace_vinfo()), info)
155 with self.assertWarns(DeprecationWarning):
156 v.trace_vdelete('r', (cb1, 43)) # Wrong arguments
157 with self.assertWarns(DeprecationWarning):
158 self.assertEqual(sorted(v.trace_vinfo()), info)
159 v.get()
160 self.assertEqual(trace, [('read', vname, '', 'r')])
161
162 trace = []
163 with self.assertWarns(DeprecationWarning) as cm:
164 v.trace_vdelete('r', cb1)
165 self.assertEqual(cm.filename, __file__)
166 with self.assertWarns(DeprecationWarning):
167 self.assertEqual(v.trace_vinfo(), [('wu', cb2)])
168 v.get()
169 self.assertEqual(trace, [])
170
171 trace = []
172 del write_tracer

Callers

nothing calls this directly

Calls 12

trace_variableMethod · 0.95
trace_vinfoMethod · 0.95
setMethod · 0.95
getMethod · 0.95
trace_vdeleteMethod · 0.95
VariableClass · 0.90
strFunction · 0.85
skipTestMethod · 0.80
assertWarnsMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected