diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -1,14 +1,14 @@ """ Tests for the threading module. """ import test.support -from test.support import verbose, strip_python_stderr, import_module, cpython_only +from test.support import verbose, strip_python_stderr, import_module, cpython_only, detect_api_mismatch from test.support.script_helper import assert_python_ok, assert_python_failure import random import re import sys _thread = import_module('_thread') threading = import_module('threading') import time @@ -1097,14 +1097,21 @@ class BoundedSemaphoreTests(lock_tests.B semtype = staticmethod(threading.BoundedSemaphore) class BarrierTests(lock_tests.BarrierTests): barriertype = staticmethod(threading.Barrier) class MiscTestCase(unittest.TestCase): def test__all__(self): extra = {"ThreadError"} - blacklist = {'currentThread', 'activeCount'} support.check__all__(self, threading, ('threading', '_thread'), - extra=extra, blacklist=blacklist) + extra=extra) + + def test_api_mismatch(self): + """Test that dummy_threading module has all threading functionality""" + import dummy_threading + mismatch = detect_api_mismatch(threading, dummy_threading, + ignore=('WeakSet',)) + self.assertEqual(mismatch, set()) + if __name__ == "__main__": unittest.main() diff --git a/Lib/threading.py b/Lib/threading.py --- a/Lib/threading.py +++ b/Lib/threading.py @@ -21,17 +21,18 @@ except ImportError: # 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__ = ['get_ident', 'active_count', 'Condition', 'current_thread', 'enumerate', 'main_thread', 'TIMEOUT_MAX', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier', 'BrokenBarrierError', 'Timer', 'ThreadError', - 'setprofile', 'settrace', 'local', 'stack_size'] + 'setprofile', 'settrace', 'local', 'stack_size', + '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: