diff --git a/tests/stdlib/test_threading_local.py b/tests/stdlib/test_threading_local.py new file mode 100644 index 0000000..ada5d8e --- /dev/null +++ b/tests/stdlib/test_threading_local.py @@ -0,0 +1,17 @@ +from eventlet.green import thread +from eventlet.green import threading +from eventlet.green import time + +from test import test_threading_local + +test_threading_local.threading = threading + +def test_main(): + import sys + sys.modules['thread'] = thread + sys.modules['threading'] = threading + sys.modules['time'] = time + test_threading_local.test_main() + +if __name__ == '__main__': + test_main() \ No newline at end of file diff --git a/tests/test_threading_local.py b/tests/test_threading_local.py deleted file mode 100644 index b8114cf..0000000 --- a/tests/test_threading_local.py +++ /dev/null @@ -1,55 +0,0 @@ -import unittest -from doctest import DocTestSuite -from tests import test_support - -class ThreadingLocalTest(unittest.TestCase): - def test_derived(self): - # Issue 3088: if there is a threads switch inside the __init__ - # of a threading.local derived class, the per-thread dictionary - # is created but not correctly set on the object. - # The first member set may be bogus. - from eventlet.green import threading - from eventlet.green import time - class Local(threading.local): - def __init__(self): - time.sleep(0.01) - local = Local() - - def f(i): - local.x = i - # Simply check that the variable is correctly set - self.assertEqual(local.x, i) - - threads= [] - for i in range(10): - t = threading.Thread(target=f, args=(i,)) - t.start() - threads.append(t) - - for t in threads: - t.join() - - -def test_main(): - suite = DocTestSuite('_threading_local') - - try: - from eventlet.green.thread import _local - except ImportError: - pass - else: - import _threading_local - local_orig = _threading_local.local - def setUp(test): - _threading_local.local = _local - def tearDown(test): - _threading_local.local = local_orig - suite.addTest(DocTestSuite('_threading_local', - setUp=setUp, tearDown=tearDown) - ) - suite.addTest(unittest.makeSuite(ThreadingLocalTest)) - - test_support.run_suite(suite) - -if __name__ == '__main__': - test_main()