Visitar URL original
Stackless issue #147: fix deprecation warnings in Stackless tests · akruis/cpython@cf473b1 · GitHub
Skip to content

Commit cf473b1

Browse files
author
Anselm Kruis
committed
Stackless issue python#147: fix deprecation warnings in Stackless tests
Don't use deprecated functions in the Stackless test suite. (cherry picked from commit 6c49d91)
1 parent 0852f81 commit cf473b1

8 files changed

Lines changed: 32 additions & 32 deletions

File tree

‎Stackless/unittests/test_defects.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def test_tasklet_end_with_wrong_recursion_level(self):
368368
# test for issue #91 https://bitbucket.org/stackless-dev/stackless/issues/91/
369369
"""A test for issue #91, wrong recursion level after tasklet re-binding
370370
371-
Assertion failed: ts->recursion_depth == 0 || (ts->st.main == NULL && prev == next), file ..\Stackless\module\scheduling.c, line 1291
371+
Assertion failed: ts->recursion_depth == 0 || (ts->st.main == NULL && prev == next), file ../Stackless/module/scheduling.c, line 1291
372372
The assertion fails with ts->recursion_depth > 0
373373
374374
It is in function

‎Stackless/unittests/test_miscell.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def t():
285285
s.throw(TaskletExit)
286286
# the tasklet should be dead
287287
stackless.run()
288-
self.assertRaisesRegexp(RuntimeError, "dead", s.run)
288+
self.assertRaisesRegex(RuntimeError, "dead", s.run)
289289

290290
def test_dead(self):
291291
c = stackless.channel()
@@ -684,7 +684,7 @@ def test_handler(self):
684684
def test_broken_handler(self):
685685
stackless.tasklet(self.func)(self.broken_handler)
686686
with self.handler_ctx(self.broken_handler):
687-
self.assertRaisesRegexp(IndexError, "mods", stackless.run)
687+
self.assertRaisesRegex(IndexError, "mods", stackless.run)
688688
self.assertTrue(self.ran)
689689
self.assertTrue(self.handled)
690690

@@ -872,13 +872,13 @@ def test_bind(self):
872872

873873
self.assertFalse(t.alive)
874874
self.assertIsNone(t.frame)
875-
self.assertEquals(t.nesting_level, 0)
875+
self.assertEqual(t.nesting_level, 0)
876876

877877
t.bind(None) # must not change the tasklet
878878

879879
self.assertFalse(t.alive)
880880
self.assertIsNone(t.frame)
881-
self.assertEquals(t.nesting_level, 0)
881+
self.assertEqual(t.nesting_level, 0)
882882

883883
t.bind(self.task)
884884
t.setup(False)
@@ -901,7 +901,7 @@ def test_bind(self):
901901
def test_bind_fail_not_callable(self):
902902
class C(object):
903903
pass
904-
self.assertRaisesRegexp(TypeError, "callable", stackless.current.bind, C())
904+
self.assertRaisesRegex(TypeError, "callable", stackless.current.bind, C())
905905

906906
def test_unbind_ok(self):
907907
if not stackless.enable_softswitch(None):
@@ -927,7 +927,7 @@ def test_unbind_ok(self):
927927
self.assertEqual(self.finally_run_count, 0)
928928

929929
def test_unbind_fail_current(self):
930-
self.assertRaisesRegexp(RuntimeError, "current tasklet", stackless.current.bind, None)
930+
self.assertRaisesRegex(RuntimeError, "current tasklet", stackless.current.bind, None)
931931

932932
def test_unbind_fail_scheduled(self):
933933
t = stackless.tasklet(self.task)(False)
@@ -939,7 +939,7 @@ def test_unbind_fail_scheduled(self):
939939
self.assertTrue(t.alive)
940940
self.assertIsInstance(t.frame, types.FrameType)
941941

942-
self.assertRaisesRegexp(RuntimeError, "scheduled", t.bind, None)
942+
self.assertRaisesRegex(RuntimeError, "scheduled", t.bind, None)
943943

944944
def test_unbind_fail_cstate(self):
945945
t = stackless.tasklet(self.task)(True)
@@ -952,7 +952,7 @@ def test_unbind_fail_cstate(self):
952952
self.assertGreaterEqual(t.nesting_level, 1)
953953
self.assertIsInstance(t.frame, types.FrameType)
954954

955-
self.assertRaisesRegexp(RuntimeError, "C state", t.bind, None)
955+
self.assertRaisesRegex(RuntimeError, "C state", t.bind, None)
956956

957957
# remove the tasklet. Must run the finally clause
958958
t = None
@@ -1181,7 +1181,7 @@ def test_switch_blocked(self):
11811181
t = stackless.tasklet(self.blocked_target)()
11821182
t.run()
11831183
self.assertTrue(t.blocked)
1184-
self.assertRaisesRegexp(RuntimeError, "blocked", t.switch)
1184+
self.assertRaisesRegex(RuntimeError, "blocked", t.switch)
11851185
self.c.send(None)
11861186
self.assertTrue(self.finished)
11871187

@@ -1196,7 +1196,7 @@ def test_switch_trapped(self):
11961196
t = stackless.tasklet(self.target)()
11971197
self.assertFalse(t.paused)
11981198
with switch_trapped():
1199-
self.assertRaisesRegexp(RuntimeError, "switch_trap", t.switch)
1199+
self.assertRaisesRegex(RuntimeError, "switch_trap", t.switch)
12001200
self.assertFalse(t.paused)
12011201
t.switch()
12021202
self.assertTrue(self.finished)
@@ -1211,7 +1211,7 @@ def test_switch_blocked_trapped(self):
12111211
t.run()
12121212
self.assertTrue(t.blocked)
12131213
with switch_trapped():
1214-
self.assertRaisesRegexp(RuntimeError, "blocked", t.switch)
1214+
self.assertRaisesRegex(RuntimeError, "blocked", t.switch)
12151215
self.assertTrue(t.blocked)
12161216
self.c.send(None)
12171217
self.assertTrue(self.finished)
@@ -1221,7 +1221,7 @@ def test_switch_paused_trapped(self):
12211221
t.bind(args=())
12221222
self.assertTrue(t.paused)
12231223
with switch_trapped():
1224-
self.assertRaisesRegexp(RuntimeError, "switch_trap", t.switch)
1224+
self.assertRaisesRegex(RuntimeError, "switch_trap", t.switch)
12251225
self.assertTrue(t.paused)
12261226
t.switch()
12271227
self.assertTrue(self.finished)

‎Stackless/unittests/test_pickle.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def f2():
579579
wrap_frame = r[0](*r[1])
580580
self.assertIsInstance(wrap_frame, stackless._wrap.frame)
581581
invalid_state = r[2][:-2] + ((("Not a", "tuple of 3", "integers"),), r[2][-1])
582-
self.assertRaisesRegexp(TypeError, "an integer is required", wrap_frame.__setstate__, invalid_state)
582+
self.assertRaisesRegex(TypeError, "an integer is required", wrap_frame.__setstate__, invalid_state)
583583
# must not raise an assertion
584584
wrap_frame.__setstate__(r[2])
585585
self.assertIs(type(wrap_frame), types.FrameType)

‎Stackless/unittests/test_sched_cb.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def cb(prev, next):
141141
stackless.set_schedule_callback(None)
142142
for real_name, ex, current_name in switches:
143143
if real_name:
144-
self.assertEquals(real_name, current_name)
144+
self.assertEqual(real_name, current_name)
145145
if ex:
146-
self.assertEquals(ex.name, current_name)
146+
self.assertEqual(ex.name, current_name)
147147

148148
def testGetCallback(self):
149149
mon = SchedulingMonitor()

‎Stackless/unittests/test_thread.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def job():
274274
def test_rebind_nontrivial(self):
275275
end, task = self.create_remote_tasklet(nontrivial=True)
276276
try:
277-
self.assertRaisesRegexp(RuntimeError, "C state", task.bind_thread)
277+
self.assertRaisesRegex(RuntimeError, "C state", task.bind_thread)
278278
finally:
279279
end()
280280

@@ -377,7 +377,7 @@ def test_rebound_tasklet_from_dead_thread(self):
377377

378378
def test_bind_runnable(self):
379379
theThread, t = self.create_thread_task()
380-
self.assertRaisesRegexp(RuntimeError, "runnable", t.bind_thread)
380+
self.assertRaisesRegex(RuntimeError, "runnable", t.bind_thread)
381381
theThread.join()
382382

383383
def test_death(self):
@@ -578,7 +578,7 @@ def tasklet_runnable_action(self):
578578
def test_rebind_runnable(self):
579579
theThread, t = self.create_thread_task(self.tasklet_runnable_action)
580580
with theThread:
581-
self.assertRaisesRegexp(RuntimeError, 'runnable', t.bind_thread)
581+
self.assertRaisesRegex(RuntimeError, 'runnable', t.bind_thread)
582582
self.channel.send(None)
583583

584584

@@ -595,7 +595,7 @@ def test_switch(self):
595595
with theThread:
596596
time.sleep(0.01)
597597
self.assertTrue(t.paused)
598-
self.assertRaisesRegexp(RuntimeError, "different thread", t.switch)
598+
self.assertRaisesRegex(RuntimeError, "different thread", t.switch)
599599

600600

601601
class SetupFromDifferentThreadTest(RemoteTaskletTests):

‎Stackless/unittests/test_tracing.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def testSetTraceOnCurrent(self):
128128
def testSetTraceOnDeadTasklet(self):
129129
t = stackless.tasklet()
130130
self.assertIsNone(t.trace_function)
131-
self.assertRaisesRegexp(RuntimeError, "tasklet is not alive",
131+
self.assertRaisesRegex(RuntimeError, "tasklet is not alive",
132132
setattr, t, "trace_function", self.nullTraceFunc)
133133

134134
def testSetProfileOnDeadTasklet(self):
135135
t = stackless.tasklet()
136136
self.assertIsNone(t.trace_function)
137-
self.assertRaisesRegexp(RuntimeError, "tasklet is not alive",
137+
self.assertRaisesRegex(RuntimeError, "tasklet is not alive",
138138
setattr, t, "profile_function", self.nullTraceFunc)
139139

140140
def testSetTraceOnTasklet1(self):

‎Stackless/unittests/test_tstate.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def testTracedMainNormalTasklet(self):
258258
self.maxDiff = None
259259
expected = [('mark', self.Tasklet2.__name__, i) for i in
260260
('start', 'before schedule', 'after schedule', 'end schedule')]
261-
self.assertEquals(trace_in_tasklet, expected)
261+
self.assertEqual(trace_in_tasklet, expected)
262262

263263
# Test the combination of Exception and Trace State
264264

@@ -336,7 +336,7 @@ def testReduceOfTracingState(self):
336336

337337
# test if the tracing cframe is present / not present
338338
self.assertListEqual(reduced_tasklet1[2][3], [frame])
339-
self.assertEquals(len(reduced_tasklet2[2][3]), 2)
339+
self.assertEqual(len(reduced_tasklet2[2][3]), 2)
340340
self.assertIs(reduced_tasklet2[2][3][0], frame)
341341
self.assertIsInstance(reduced_tasklet2[2][3][1], stackless.cframe)
342342

‎Stackless/unittests/test_watchdog.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,26 +340,26 @@ class TestDeadlock(StacklessTestCase):
340340
def testReceiveOnMain(self):
341341
"""Thest that we get a deadock exception if main tries to block"""
342342
self.c = stackless.channel()
343-
self.assertRaisesRegexp(RuntimeError, "Deadlock", self.c.receive)
343+
self.assertRaisesRegex(RuntimeError, "Deadlock", self.c.receive)
344344

345345
def test_main_receiving_endttasklet(self):
346346
"""Test that the main tasklet is interrupted when a tasklet ends"""
347347
c = stackless.channel()
348348
t = stackless.tasklet(lambda: None)()
349-
self.assertRaisesRegexp(RuntimeError, "receiving", c.receive)
349+
self.assertRaisesRegex(RuntimeError, "receiving", c.receive)
350350

351351
def test_main_sending_enddtasklet(self):
352352
"""Test that the main tasklet is interrupted when a tasklet ends"""
353353
c = stackless.channel()
354354
t = stackless.tasklet(lambda: None)()
355-
self.assertRaisesRegexp(RuntimeError, "sending", c.send, None)
355+
self.assertRaisesRegex(RuntimeError, "sending", c.send, None)
356356

357357
def test_main_gets_exception(self):
358358
"""Test that a custom exception is transfered to a blocked main"""
359359
def task():
360360
raise ZeroDivisionError("mumbai")
361361
stackless.tasklet(task)()
362-
self.assertRaisesRegexp(ZeroDivisionError, "mumbai", stackless.channel().receive)
362+
self.assertRaisesRegex(ZeroDivisionError, "mumbai", stackless.channel().receive)
363363

364364
@require_one_thread
365365
def test_tasklet_deadlock(self):
@@ -368,7 +368,7 @@ def test_tasklet_deadlock(self):
368368

369369
def task():
370370
c = stackless.channel()
371-
self.assertRaisesRegexp(RuntimeError, "Deadlock", c.receive)
371+
self.assertRaisesRegex(RuntimeError, "Deadlock", c.receive)
372372
mc.send(None)
373373
t = stackless.tasklet(task)()
374374
mc.receive()
@@ -382,7 +382,7 @@ def task():
382382
stackless.channel().receive()
383383
t = stackless.tasklet(task)()
384384
# main should get the tasklet's exception
385-
self.assertRaisesRegexp(RuntimeError, "Deadlock", mc.receive)
385+
self.assertRaisesRegex(RuntimeError, "Deadlock", mc.receive)
386386

387387
def test_error_propagation_when_not_deadlock(self):
388388
def task1():
@@ -393,7 +393,7 @@ def task2():
393393

394394
t1 = stackless.tasklet(task1)()
395395
t2 = stackless.tasklet(task2)()
396-
self.assertRaisesRegexp(ZeroDivisionError, "bar", stackless.run)
396+
self.assertRaisesRegex(ZeroDivisionError, "bar", stackless.run)
397397

398398

399399
class TestNewWatchdog(StacklessTestCase):
@@ -478,7 +478,7 @@ def errfunc():
478478

479479
def runner_func():
480480
stackless.tasklet(errfunc)()
481-
self.assertRaisesRegexp(RuntimeError, "foo", stackless.run)
481+
self.assertRaisesRegex(RuntimeError, "foo", stackless.run)
482482
self.done += 1
483483
stackless.tasklet(runner_func)()
484484
stackless.run()

0 commit comments

Comments
 (0)