8000 merge 3.3-slp (Stackless #116) · akruis/cpython@ee7479d · GitHub
[go: up one dir, main page]

Skip to 8000 content

Commit ee7479d

Browse files
author
Anselm Kruis
committed
merge 3.3-slp (Stackless python#116)
2 parents 5dbc669 + 1f0db09 commit ee7479d

18 files changed

+69
-6
lines changed

Stackless/unittests/runAll.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
"""
22
runAll.py
33
4-
Runs all testcases in files named test_*.py.
4+
Runs all test-cases in files named test_*.py.
55
Should be run in the folder Stackless/unittests.
6+
7+
This driver reuses the CPython test.regrtest driver and
8+
supports its options.
69
"""
10+
from __future__ import absolute_import
711

812
import os
9-
import unittest
13+
# just to make sure, it can be imported
14+
import support # @UnusedImport
15+
16+
from test import regrtest
17+
from test import __path__ as test_path
18+
19+
# path of the Stackless unittest directory
20+
path = os.path.split(__file__)[0]
21+
# add the stackless unittest dir to the package "test"
22+
test_path.insert(0, path)
23+
24+
# monkey patch: remove all standard tests
25+
del regrtest.STDTESTS[:]
1026

1127

1228
def main():
13-
path = os.path.split(__file__)[0]
14-
print(path)
15-
testSuite = unittest.TestLoader().discover(path)
16-
unittest.TextTestRunner(verbosity=2).run(testSuite)
29+
return regrtest.main(testdir=path)
1730

1831
if __name__ == '__main__':
1932
main()

Stackless/unittests/support.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io
3333
import contextlib
3434
import gc
35+
from test.support import run_unittest
3536

3637
# emit warnings about uncollectable objects
3738
gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
@@ -440,3 +441,23 @@ def helper():
440441
result = c.receive()
441442
assert self._ran_AsTaskletTestCase_setUp
442443
return result
444+
445+
446+
def test_main():
447+
"""Main function for the CPython :mod:`test.regrtest` test driver.
448+
449+
Import this function into your test_ module. It uses introspection
450+
to find the module name and run your tests.
451+
"""
452+
stack = inspect.stack(0)
453+
for i in range(1, 5):
454+
try:
455+
the_module = stack[i][0].f_locals["the_module"]
456+
break
457+
except KeyError:
458+
pass
459+
else:
460+
raise RuntimeError("can't find local variable 'the_module'")
461+
462+
test_suite = unittest.TestLoader().loadTestsFromModule(the_module)
463+
return run_unittest(test_suite)

Stackless/unittests/test_chan_cb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import absolute_import
12
import unittest
23

34
f A3E2 rom support import StacklessTestCase
5+
from support import test_main # @UnusedImport
46

57

68
class ChannelMonitor:

Stackless/unittests/test_channel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
import unittest
23
import stackless
34
try:
@@ -8,6 +9,7 @@
89
import sys
910
import traceback
1011
import contextlib
12+
from support import test_main # @UnusedImport
1113
from support import StacklessTestCase, require_one_thread
1214

1315

Stackless/unittests/test_defects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
withThreads = False
1414

1515
from stackless import _test_nostacklesscall as apply_not_stackless
16+
from support import test_main # @UnusedImport
1617
from support import StacklessTestCase, captured_stderr, require_one_thread
1718

1819

Stackless/unittests/test_exception.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import absolute_import
12
import unittest
23

4+
from support import test_main # @UnusedImport
35
from support import StacklessTestCase
46

57

Stackless/unittests/test_generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
from __future__ import absolute_import
12
import unittest
23
import gc
34
import stackless
45
import types
56

7+
from support import test_main # @UnusedImport
68
from support import StacklessTestCase
79

810

Stackless/unittests/test_miscell.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import absolute_import
12
# import common
23

34
import unittest
@@ -18,6 +19,7 @@
1819
except:
1920
withThreads = False
2021

22+
from support import test_main # @UnusedImport
2123
from support import StacklessTestCase, AsTaskletTestCase, require_one_thread
2224

2325

Stackless/unittests/test_outside.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from __future__ import absolute_import
12
import unittest
23
from stackless import test_cframe, test_cframe_nr, test_outside, test_cstate
34
from stackless import tasklet, channel, run
45

6+
from support import test_main # @UnusedImport
57
from support import StacklessTestCase
68

79

Stackless/unittests/test_pickle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from stackless import schedule, tasklet, stackless
88

9+
from support import test_main # @UnusedImport
910
from support import StacklessTestCase, StacklessPickleTestCase
1011

1112

0 commit comments

Comments
 (0)
0