50
50
withThreads = False
51
51
from support import test_main # @UnusedImport
52
52
from support import StacklessTestCase
53
+ from textwrap import dedent
53
54
54
55
55
56
@unittest .skipUnless (withThreads , "requires thread support" )
@@ -135,7 +136,9 @@ def test_deep_thread(self):
135
136
if not stackless .enable_softswitch (None ):
136
137
args .append ("--hard" )
137
138
138
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
139
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
140
+ from __future__ import print_function, absolute_import
141
+
139
142
import threading
140
143
import stackless
141
144
import time
@@ -163,7 +166,7 @@ def recurse():
163
166
# print("end")
164
167
sys.stdout.flush()
165
168
sys.exit(42)
166
- """ ] + args )
169
+ """ ) ] + args )
167
170
self .assertEqual (rc , 42 )
168
171
169
172
def test_deep_tasklets (self ):
@@ -173,7 +176,9 @@ def test_deep_tasklets(self):
173
176
if not stackless .enable_softswitch (None ):
174
177
args .append ("--hard" )
175
178
176
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
179
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
180
+ from __future__ import print_function, absolute_import
181
+
177
182
import stackless
178
183
import sys
179
184
from stackless import _test_nostacklesscall as apply
@@ -199,7 +204,7 @@ def recurse():
199
204
# print("end")
200
205
sys.stdout.flush()
201
206
sys.exit(42)
202
- """ ] + args )
207
+ """ ) ] + args )
203
208
self .assertEqual (rc , 42 )
204
209
205
210
def test_exit_in_deep_tasklet1 (self ):
@@ -209,7 +214,9 @@ def test_exit_in_deep_tasklet1(self):
209
214
if not stackless .enable_softswitch (None ):
210
215
args .append ("--hard" )
211
216
212
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
217
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
218
+ from __future__ import print_function, absolute_import
219
+
213
220
import stackless
214
221
import sys
215
222
from stackless import _test_nostacklesscall as apply
@@ -241,7 +248,7 @@ def recurse():
241
248
print("OOPS, must not be reached")
242
249
sys.stdout.flush()
243
250
sys.exit(44)
244
- """ ] + args )
251
+ """ ) ] + args )
245
252
self .assertEqual (rc , 42 )
246
253
247
254
def test_exit_in_deep_tasklet2 (self ):
@@ -251,7 +258,9 @@ def test_exit_in_deep_tasklet2(self):
251
258
if not stackless .enable_softswitch (None ):
252
259
args .append ("--hard" )
253
260
254
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
261
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
262
+ from __future__ import print_function, absolute_import
263
+
255
264
import stackless
256
265
import sys
257
266
from stackless import _test_nostacklesscall as apply
@@ -288,7 +297,7 @@ def recurse():
288
297
print("OOPS, must not be reached")
289
298
sys.stdout.flush()
290
299
sys.exit(44)
291
- """ ] + args )
300
+ """ ) ] + args )
292
301
self .assertEqual (rc , 42 )
293
302
294
303
def test_deep_Py_Exit (self ):
@@ -302,7 +311,9 @@ def test_deep_Py_Exit(self):
302
311
if not stackless .enable_softswitch (None ):
303
312
args .append ("--hard" )
304
313
305
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
314
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
315
+ from __future__ import print_function, absolute_import
316
+
306
317
import stackless
307
318
import sys
308
319
import ctypes
@@ -329,7 +340,7 @@ def recurse():
329
340
print("OOPS, must not be reached")
330
341
sys.stdout.flush()
331
342
sys.exit(43)
332
- """ ] + args )
343
+ """ ) ] + args )
333
344
self .assertEqual (rc , 42 )
334
345
335
346
@unittest .skipUnless (withThreads , "requires thread support" )
@@ -344,7 +355,9 @@ def test_other_thread_Py_Exit(self):
344
355
if not stackless .enable_softswitch (None ):
345
356
args .append ("--hard" )
346
357
347
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import\n if 1:
358
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
359
+ from __future__ import print_function, absolute_import
360
+
348
361
import stackless
349
362
import sys
350
363
import ctypes
@@ -372,7 +385,7 @@ def exit():
372
385
print("OOPS, must not be reached")
373
386
sys.stdout.flush()
374
387
sys.exit(43)
375
- """ ] + args )
388
+ """ ) ] + args )
376
389
self .assertEqual (rc , 42 )
377
390
378
391
@unittest .skipUnless (withThreads , "requires thread support" )
@@ -383,7 +396,9 @@ def test_kill_modifies_slp_cstack_chain(self):
383
396
if not stackless .enable_softswitch (None ):
384
397
args .append ("--hard" )
385
398
386
- rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , """from __future__ import print_function, absolute_import, division\n if 1:
399
+ rc = subprocess .call ([sys .executable , "-s" , "-S" , "-E" , "-c" , dedent ("""
400
+ from __future__ import print_function, absolute_import, division
401
+
387
402
import threading
388
403
import stackless
389
404
import time
@@ -447,7 +462,7 @@ def other_thread():
447
462
event.wait(5.0)
448
463
print("end")
449
464
sys.exit(42)
450
- """ ] + args )
465
+ """ ) ] + args )
451
466
self .assertEqual (rc , 42 )
452
467
453
468
0 commit comments