diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-08-18 22:10:13 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-08-18 22:10:13 (GMT) |
commit | f0923f521077d3592fb49edded540289686cfd68 (patch) | |
tree | 82bceeb4fab696aeeec39e195b2fca3ff4837a70 /Lib/test/test_threading.py | |
parent | 2faaeceb1566701886c37f40fe94c0d6b8a94aea (diff) | |
download | cpython-f0923f521077d3592fb49edded540289686cfd68.zip cpython-f0923f521077d3592fb49edded540289686cfd68.tar.gz cpython-f0923f521077d3592fb49edded540289686cfd68.tar.bz2 |
add full deprecation warnings for old threading APIs
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r-- | Lib/test/test_threading.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index b36c196..6458f7e 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -1,7 +1,7 @@ # Very rudimentary test of threading module import test.support -from test.support import verbose +from test.support import verbose, catch_warning import random import re import sys @@ -323,6 +323,43 @@ class ThreadTests(unittest.TestCase): msg=('%d references still around' % sys.getrefcount(weak_raising_cyclic_object()))) + def test_pep8ified_threading(self): + import threading + + def check(_, w, msg): + self.assertEqual(str(w.message), msg) + + t = threading.Thread() + with catch_warning() as w: + msg = "isDaemon() is deprecated in favor of the " \ + "Thread.daemon property" + check(t.isDaemon(), w, msg) + w.reset() + msg = "setDaemon() is deprecated in favor of the " \ + "Thread.daemon property" + check(t.setDaemon(True), w, msg) + w.reset() + msg = "getName() is deprecated in favor of the " \ + "Thread.name property" + check(t.getName(), w, msg) + w.reset() + msg = "setName() is deprecated in favor of the " \ + "Thread.name property" + check(t.setName("name"), w, msg) + w.reset() + msg = "isAlive() is deprecated in favor of is_alive()" + check(t.isAlive(), w, msg) + w.reset() + e = threading.Event() + msg = "isSet() is deprecated in favor of is_set()" + check(e.isSet(), w, msg) + w.reset() + msg = "currentThread() is deprecated in favor of current_thread()" + check(threading.currentThread(), w, msg) + w.reset() + msg = "activeCount() is deprecated in favor of active_count()" + check(threading.activeCount(), w, msg) + class ThreadJoinOnShutdown(unittest.TestCase): |