summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2021-04-12 08:42:53 (GMT)
committerGitHub <noreply@github.com>2021-04-12 08:42:53 (GMT)
commit9825bdfbd5c966abf1f1b7264992d722a94c9613 (patch)
tree393e11e62ed0c808010af578fbb0cb4afd00b0c6 /Lib/test/test_threading.py
parentcc2ffcdfd78df3a18edae60df81b2f1b044b1634 (diff)
downloadcpython-9825bdfbd5c966abf1f1b7264992d722a94c9613.zip
cpython-9825bdfbd5c966abf1f1b7264992d722a94c9613.tar.gz
cpython-9825bdfbd5c966abf1f1b7264992d722a94c9613.tar.bz2
bpo-43723: Deprecate camelCase aliases from threading (GH-25174)
The snake_case names have existed since Python 2.6, so there is no reason to keep the old camelCase names around. One similar method, threading.Thread.isAlive, was already removed in Python 3.9 (bpo-37804).
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 933935b..49a4af8 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -154,9 +154,9 @@ class ThreadTests(BaseTestCase):
def test_ident_of_no_threading_threads(self):
# The ident still must work for the main thread and dummy threads.
- self.assertIsNotNone(threading.currentThread().ident)
+ self.assertIsNotNone(threading.current_thread().ident)
def f():
- ident.append(threading.currentThread().ident)
+ ident.append(threading.current_thread().ident)
done.set()
done = threading.Event()
ident = []
@@ -447,13 +447,32 @@ class ThreadTests(BaseTestCase):
# Just a quick sanity check to make sure the old method names are
# still present
t = threading.Thread()
- t.isDaemon()
- t.setDaemon(True)
- t.getName()
- t.setName("name")
+ with self.assertWarnsRegex(DeprecationWarning,
+ r'get the daemon attribute'):
+ t.isDaemon()
+ with self.assertWarnsRegex(DeprecationWarning,
+ r'set the daemon attribute'):
+ t.setDaemon(True)
+ with self.assertWarnsRegex(DeprecationWarning,
+ r'get the name attribute'):
+ t.getName()
+ with self.assertWarnsRegex(DeprecationWarning,
+ r'set the name attribute'):
+ t.setName("name")
+
e = threading.Event()
- e.isSet()
- threading.activeCount()
+ with self.assertWarnsRegex(DeprecationWarning, 'use is_set()'):
+ e.isSet()
+
+ cond = threading.Condition()
+ cond.acquire()
+ with self.assertWarnsRegex(DeprecationWarning, 'use notify_all()'):
+ cond.notifyAll()
+
+ with self.assertWarnsRegex(DeprecationWarning, 'use active_count()'):
+ threading.activeCount()
+ with self.assertWarnsRegex(DeprecationWarning, 'use current_thread()'):
+ threading.currentThread()
def test_repr_daemon(self):
t = threading.Thread()