MCPcopy
hub / github.com/tornadoweb/tornado / run_subprocess

Method run_subprocess

tornado/test/autoreload_test.py:73–105  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

71 f.write(textwrap.dedent(contents))
72
73 def run_subprocess(self, args):
74 # Make sure the tornado module under test is available to the test
75 # application
76 parts = [os.getcwd()]
77 if "PYTHONPATH" in os.environ:
78 parts += [
79 os.path.join(os.getcwd(), part)
80 for part in os.environ["PYTHONPATH"].split(os.pathsep)
81 ]
82 pythonpath = os.pathsep.join(parts)
83
84 p = Popen(
85 args,
86 stdout=subprocess.PIPE,
87 env=dict(os.environ, PYTHONPATH=pythonpath),
88 cwd=self.path,
89 universal_newlines=True,
90 encoding="utf-8",
91 )
92
93 # This timeout needs to be fairly generous for pypy due to jit
94 # warmup costs.
95 for i in range(40):
96 if p.poll() is not None:
97 break
98 time.sleep(0.1)
99 else:
100 p.kill()
101 raise Exception("subprocess failed to terminate")
102
103 out = p.communicate()[0]
104 self.assertEqual(p.returncode, 0)
105 return out
106
107 def test_reload(self):
108 main = """\

Calls 2

joinMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected