diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/isolated/patcher_threading_original.py | 31 | ||||
| -rw-r--r-- | tests/patcher_test.py | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/isolated/patcher_threading_original.py b/tests/isolated/patcher_threading_original.py new file mode 100644 index 0000000..42bb107 --- /dev/null +++ b/tests/isolated/patcher_threading_original.py @@ -0,0 +1,31 @@ +import sys +import threading + + +# no standard tests in this file, ignore +__test__ = False + + +class ImportEventlet(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.same_module = None + + def run(self): + # https://github.com/eventlet/eventlet/issues/230 + # Test importing eventlet for the first time in a thread: + # eventlet.patcher.original() must not reload threading.py twice. + mod1 = sys.modules['threading'] + import eventlet.patcher + mod2 = eventlet.patcher.original('threading') + self.same_module = mod2 is mod1 + + +if __name__ == '__main__': + thread = ImportEventlet() + thread.start() + thread.join() + if thread.same_module: + print("pass") + else: + print("failed") diff --git a/tests/patcher_test.py b/tests/patcher_test.py index 2e458c5..1fe54fe 100644 --- a/tests/patcher_test.py +++ b/tests/patcher_test.py @@ -504,5 +504,10 @@ def test_threading_condition(): tests.run_isolated('patcher_threading_condition.py') +def test_threading_original(): + # https://github.com/eventlet/eventlet/issues/230 test for non-regression of threading+original() + tests.run_isolated('patcher_threading_original.py') + + def test_threading_join(): tests.run_isolated('patcher_threading_join.py') |
