[pypy-commit] pypy py3.5: Give up on trying to get test_multithreaded_import() to work untranslated
rlamy
pypy.commits at gmail.com
Thu Dec 14 16:02:56 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r93423:b3b1beda9224
Date: 2017-12-14 21:02 +0000
http://bitbucket.org/pypy/pypy/changeset/b3b1beda9224/
Log: Give up on trying to get test_multithreaded_import() to work
untranslated
diff --git a/extra_tests/test_import.py b/extra_tests/test_import.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_import.py
@@ -0,0 +1,41 @@
+import pytest
+import sys
+import time
+from _thread import start_new_thread
+
+ at pytest.mark.xfail('__pypy__' not in sys.builtin_module_names,
+ reason='Fails on CPython')
+def test_multithreaded_import(tmpdir):
+ tmpfile = tmpdir.join('multithreaded_import_test.py')
+ tmpfile.write('''if 1:
+ x = 666
+ import time
+ for i in range(1000): time.sleep(0.001)
+ x = 42
+ ''')
+
+ oldpath = sys.path[:]
+ try:
+ sys.path.insert(0, str(tmpdir))
+ got = []
+
+ def check():
+ import multithreaded_import_test
+ got.append(getattr(multithreaded_import_test, 'x', '?'))
+
+ for i in range(5):
+ start_new_thread(check, ())
+
+ for n in range(100):
+ for i in range(105):
+ time.sleep(0.001)
+ if len(got) == 5:
+ break
+ else:
+ raise AssertionError("got %r so far but still waiting" %
+ (got,))
+
+ assert got == [42] * 5
+
+ finally:
+ sys.path[:] = oldpath
diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -1249,46 +1249,3 @@
spaceconfig = {
"translation.sandbox": True
}
-
-
-class AppTestMultithreadedImp(object):
- spaceconfig = dict(usemodules=['thread', 'time'])
-
- def setup_class(cls):
- #if not conftest.option.runappdirect:
- # py.test.skip("meant as an -A test")
- tmpfile = udir.join('test_multithreaded_imp.py')
- tmpfile.write('''if 1:
- x = 666
- import time
- for i in range(1000): time.sleep(0.001)
- x = 42
- ''')
- cls.w_tmppath = cls.space.wrap(str(udir))
-
- def test_multithreaded_import(self):
- import sys, _thread, time
- oldpath = sys.path[:]
- try:
- sys.path.insert(0, self.tmppath)
- got = []
-
- def check():
- import test_multithreaded_imp
- got.append(getattr(test_multithreaded_imp, 'x', '?'))
-
- for i in range(5):
- _thread.start_new_thread(check, ())
-
- for n in range(100):
- for i in range(105): time.sleep(0.001)
- if len(got) == 5:
- break
- else:
- raise AssertionError("got %r so far but still waiting" %
- (got,))
-
- assert got == [42] * 5, got
-
- finally:
- sys.path[:] = oldpath
More information about the pypy-commit
mailing list