tests: str/bytes typo on run_python timeout
This commit is contained in:
parent
df0d300e7e
commit
4872be7700
|
@ -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')
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue