diff options
| author | Sergey Shepelev <temotor@gmail.com> | 2016-11-05 19:28:14 +0300 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2016-11-05 22:43:35 +0300 |
| commit | 4872be77001bde7b393f8973779a15c65ce36086 (patch) | |
| tree | d6b2fecc438a9134dc2ec652b34231dee958630e | |
| parent | df0d300e7e60661b80346f31815e5266bb302c57 (diff) | |
| download | eventlet-4872be77001bde7b393f8973779a15c65ce36086.tar.gz | |
tests: str/bytes typo on run_python timeout
| -rw-r--r-- | tests/__init__.py | 9 | ||||
| -rw-r--r-- | tests/patcher_test.py | 24 |
2 files changed, 18 insertions, 15 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index b9e0add..6ff6d2a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -306,8 +306,6 @@ def run_python(path, env=None, args=None, timeout=None): new_argv = [sys.executable] new_env = os.environ.copy() if path: - if not path.endswith('.py'): - path += '.py' path = os.path.abspath(path) new_argv.append(path) src_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -330,7 +328,7 @@ def run_python(path, env=None, args=None, timeout=None): except subprocess.TimeoutExpired: p.kill() output, _ = p.communicate(timeout=timeout) - return "{0}\nFAIL - timed out".format(output) + return '{0}\nFAIL - timed out'.format(output).encode() return output @@ -350,3 +348,8 @@ def run_isolated(path, prefix='tests/isolated/', env=None, args=None, timeout=No certificate_file = os.path.join(os.path.dirname(__file__), 'test_server.crt') private_key_file = os.path.join(os.path.dirname(__file__), 'test_server.key') + + +def test_run_python_timeout(): + output = run_python('', args=('-c', 'import time; time.sleep(0.5)'), timeout=0.1) + assert output.endswith(b'FAIL - timed out') diff --git a/tests/patcher_test.py b/tests/patcher_test.py index ec51436..fb9c19b 100644 --- a/tests/patcher_test.py +++ b/tests/patcher_test.py @@ -323,7 +323,7 @@ print(len(threading._active)) print(len(_threading._active)) """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 4, "\n".join(lines)) assert lines[0].startswith('<Thread'), lines[0] assert lines[1] == '1', lines @@ -341,7 +341,7 @@ t.join() print(len(threading._active)) """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) assert lines[0].startswith('<_MainThread'), lines[0] self.assertEqual(lines[1], "1", lines[1]) @@ -357,7 +357,7 @@ tpool.execute(test) print(len(threading._active)) """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) assert lines[0].startswith('<Thread'), lines[0] self.assertEqual(lines[1], "1", lines[1]) @@ -376,7 +376,7 @@ evt.wait() print(len(threading._active)) """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) assert lines[0].startswith('<_MainThread'), lines[0] self.assertEqual(lines[1], "1", lines[1]) @@ -392,7 +392,7 @@ t.wait() print(len(threading._active)) """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) assert lines[0].startswith('<_GreenThread'), lines[0] self.assertEqual(lines[1], "1", lines[1]) @@ -402,7 +402,7 @@ print(len(threading._active)) eventlet.monkey_patch() """ self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 1, "\n".join(lines)) @@ -414,7 +414,7 @@ eventlet.monkey_patch(all=False, os=True) process = subprocess.Popen("sleep 0.1 && false", shell=True) print(process.wait())""" self.write_to_tempfile("newmod", new_mod) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 2, "\n".join(lines)) self.assertEqual('1', lines[0], repr(output)) @@ -441,7 +441,7 @@ t.wait() print(repr(t2)) t2.join() """) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 2, "\n".join(lines)) assert lines[0].startswith('<_GreenThread'), lines[0] @@ -459,7 +459,7 @@ t2.join() print(t.getName()) print(t.get_name()) """ + self.epilogue) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 10, "\n".join(lines)) for i in range(0, 3): self.assertEqual(lines[i], "GreenThread-1", lines[i]) @@ -473,7 +473,7 @@ t2.join() print(id(t._g)) print(t.ident) """ + self.epilogue) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) self.assertEqual(lines[0], lines[1]) @@ -482,7 +482,7 @@ t2.join() print(t.is_alive()) print(t.isAlive()) """ + self.epilogue) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) self.assertEqual(lines[0], "True", lines[0]) self.assertEqual(lines[1], "True", lines[1]) @@ -492,7 +492,7 @@ t2.join() print(t.is_daemon()) print(t.isDaemon()) """ + self.epilogue) - output, lines = self.launch_subprocess('newmod') + output, lines = self.launch_subprocess('newmod.py') self.assertEqual(len(lines), 3, "\n".join(lines)) self.assertEqual(lines[0], "True", lines[0]) self.assertEqual(lines[1], "True", lines[1]) |
