forked from goodboy/tractor
Search for guard and strip instead of hardcoding
parent
cfc97c4204
commit
d62610c44e
|
@ -2,6 +2,7 @@
|
||||||
Let's make sure them docs work yah?
|
Let's make sure them docs work yah?
|
||||||
"""
|
"""
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
import itertools
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -42,9 +43,13 @@ def run_example_in_subproc(loglevel, testdir, arb_addr):
|
||||||
os.path.join(str(testdir), '__main__.py')
|
os.path.join(str(testdir), '__main__.py')
|
||||||
)
|
)
|
||||||
|
|
||||||
# drop the ``if __name__ == '__main__'`` guard from the *NIX
|
# drop the ``if __name__ == '__main__'`` guard onwards from
|
||||||
# version of each script
|
# the *NIX version of each script
|
||||||
script_code = '\n'.join(script_code.splitlines()[:-4])
|
windows_script_lines = itertools.takewhile(
|
||||||
|
lambda line: "if __name__ ==" not in line,
|
||||||
|
script_code.splitlines()
|
||||||
|
)
|
||||||
|
script_code = '\n'.join(windows_script_lines)
|
||||||
script_file = testdir.makefile('.py', script_code)
|
script_file = testdir.makefile('.py', script_code)
|
||||||
|
|
||||||
# without this, tests hang on windows forever
|
# without this, tests hang on windows forever
|
||||||
|
|
Loading…
Reference in New Issue