Skip to content

Commit

Permalink
merge 3.4-slp (use dedent for inline scripts)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Kruis committed Mar 29, 2017
2 parents 930d946 + 30770d7 commit f7d91c7
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions Stackless/unittests/test_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
withThreads = False
from support import test_main # @UnusedImport
from support import StacklessTestCase
from textwrap import dedent


@unittest.skipUnless(withThreads, "requires thread support")
Expand Down Expand Up @@ -135,7 +136,9 @@ def test_deep_thread(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import threading
import stackless
import time
Expand Down Expand Up @@ -163,7 +166,7 @@ def recurse():
# print("end")
sys.stdout.flush()
sys.exit(42)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

def test_deep_tasklets(self):
Expand All @@ -173,7 +176,9 @@ def test_deep_tasklets(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import stackless
import sys
from stackless import _test_nostacklesscall as apply
Expand All @@ -199,7 +204,7 @@ def recurse():
# print("end")
sys.stdout.flush()
sys.exit(42)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

def test_exit_in_deep_tasklet1(self):
Expand All @@ -209,7 +214,9 @@ def test_exit_in_deep_tasklet1(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import stackless
import sys
from stackless import _test_nostacklesscall as apply
Expand Down Expand Up @@ -241,7 +248,7 @@ def recurse():
print("OOPS, must not be reached")
sys.stdout.flush()
sys.exit(44)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

def test_exit_in_deep_tasklet2(self):
Expand All @@ -251,7 +258,9 @@ def test_exit_in_deep_tasklet2(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import stackless
import sys
from stackless import _test_nostacklesscall as apply
Expand Down Expand Up @@ -288,7 +297,7 @@ def recurse():
print("OOPS, must not be reached")
sys.stdout.flush()
sys.exit(44)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

def test_deep_Py_Exit(self):
Expand All @@ -302,7 +311,9 @@ def test_deep_Py_Exit(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import stackless
import sys
import ctypes
Expand All @@ -329,7 +340,7 @@ def recurse():
print("OOPS, must not be reached")
sys.stdout.flush()
sys.exit(43)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

@unittest.skipUnless(withThreads, "requires thread support")
Expand All @@ -344,7 +355,9 @@ def test_other_thread_Py_Exit(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import
import stackless
import sys
import ctypes
Expand Down Expand Up @@ -372,7 +385,7 @@ def exit():
print("OOPS, must not be reached")
sys.stdout.flush()
sys.exit(43)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)

@unittest.skipUnless(withThreads, "requires thread support")
Expand All @@ -383,7 +396,9 @@ def test_kill_modifies_slp_cstack_chain(self):
if not stackless.enable_softswitch(None):
args.append("--hard")

rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", """from __future__ import print_function, absolute_import, division\nif 1:
rc = subprocess.call([sys.executable, "-s", "-S", "-E", "-c", dedent("""
from __future__ import print_function, absolute_import, division
import threading
import stackless
import time
Expand Down Expand Up @@ -447,7 +462,7 @@ def other_thread():
event.wait(5.0)
print("end")
sys.exit(42)
"""] + args)
""")] + args)
self.assertEqual(rc, 42)


Expand Down

0 comments on commit f7d91c7

Please sign in to comment.