diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py --- a/Lib/test/test_dummy_threading.py +++ b/Lib/test/test_dummy_threading.py @@ -51,10 +51,21 @@ class DummyThreadingTestCase(unittest.Te if support.verbose: print('waiting for all tasks to complete') for t in self.threads: t.join() if support.verbose: print('all tasks done') + def test_get_ident(self): + self.assertEqual(_threading.get_ident(), -1) + + def test_api_mismatch(self): + import threading + ignore = ('WeakSet', 'BrokenBarrierError', 'TIMEOUT_MAX') + mismatch = support.detect_api_mismatch(threading, _threading, + ignore=ignore) + msg = 'dummy_threading does not have all members of the threading API' + self.assertEqual(mismatch, set(), msg=msg) + if __name__ == '__main__': unittest.main() diff --git a/Lib/threading.py b/Lib/threading.py --- a/Lib/threading.py +++ b/Lib/threading.py @@ -18,18 +18,23 @@ except ImportError: # language. Those original names are not in any imminent danger of # being deprecated (even for Py3k),so this module provides them as an # alias for the PEP 8 compliant names # Note that using the new PEP 8 compliant names facilitates substitution # with the multiprocessing module, which doesn't provide the old # Java inspired names. __all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event', - 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier', - 'Timer', 'ThreadError', 'setprofile', 'settrace', 'local', 'stack_size'] + 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', + 'Barrier', 'Timer', 'ThreadError', 'setprofile', 'settrace', + 'local', 'stack_size', 'get_ident', 'main_thread', + # add deprecated aliases to stay compatible with + # dummy_threading module + 'currentThread', 'activeCount', + ] # Rename some stuff so "from threading import *" is safe _start_new_thread = _thread.start_new_thread _allocate_lock = _thread.allocate_lock _set_sentinel = _thread._set_sentinel get_ident = _thread.get_ident ThreadError = _thread.error try: