Skip to content

Commit

Permalink
merge 3.3-slp (Stackless python#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Kruis committed Jan 5, 2017
2 parents 5dbc669 + 1f0db09 commit ee7479d
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Stackless/unittests/runAll.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
"""
runAll.py
Runs all testcases in files named test_*.py.
Runs all test-cases in files named test_*.py.
Should be run in the folder Stackless/unittests.
This driver reuses the CPython test.regrtest driver and
supports its options.
"""
from __future__ import absolute_import

import os
import unittest
# just to make sure, it can be imported
import support # @UnusedImport

from test import regrtest
from test import __path__ as test_path

# path of the Stackless unittest directory
path = os.path.split(__file__)[0]
# add the stackless unittest dir to the package "test"
test_path.insert(0, path)

# monkey patch: remove all standard tests
del regrtest.STDTESTS[:]


def main():
path = os.path.split(__file__)[0]
print(path)
testSuite = unittest.TestLoader().discover(path)
unittest.TextTestRunner(verbosity=2).run(testSuite)
return regrtest.main(testdir=path)

if __name__ == '__main__':
main()
Expand Down
21 changes: 21 additions & 0 deletions Stackless/unittests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io
import contextlib
import gc
from test.support import run_unittest

# emit warnings about uncollectable objects
gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
Expand Down Expand Up @@ -440,3 +441,23 @@ def helper():
result = c.receive()
assert self._ran_AsTaskletTestCase_setUp
return result


def test_main():
"""Main function for the CPython :mod:`test.regrtest` test driver.
Import this function into your test_ module. It uses introspection
to find the module name and run your tests.
"""
stack = inspect.stack(0)
for i in range(1, 5):
try:
the_module = stack[i][0].f_locals["the_module"]
break
except KeyError:
pass
else:
raise RuntimeError("can't find local variable 'the_module'")

test_suite = unittest.TestLoader().loadTestsFromModule(the_module)
return run_unittest(test_suite)
2 changes: 2 additions & 0 deletions Stackless/unittests/test_chan_cb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import absolute_import
import unittest

from support import StacklessTestCase
from support import test_main # @UnusedImport


class ChannelMonitor:
Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_channel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
import unittest
import stackless
try:
Expand All @@ -8,6 +9,7 @@
import sys
import traceback
import contextlib
from support import test_main # @UnusedImport
from support import StacklessTestCase, require_one_thread


Expand Down
1 change: 1 addition & 0 deletions Stackless/unittests/test_defects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
withThreads = False

from stackless import _test_nostacklesscall as apply_not_stackless
from support import test_main # @UnusedImport
from support import StacklessTestCase, captured_stderr, require_one_thread


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_exception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import
import unittest

from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import
import unittest
import gc
import stackless
import types

from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_miscell.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
# import common

import unittest
Expand All @@ -18,6 +19,7 @@
except:
withThreads = False

from support import test_main # @UnusedImport
from support import StacklessTestCase, AsTaskletTestCase, require_one_thread


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_outside.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import
import unittest
from stackless import test_cframe, test_cframe_nr, test_outside, test_cstate
from stackless import tasklet, channel, run

from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
1 change: 1 addition & 0 deletions Stackless/unittests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from stackless import schedule, tasklet, stackless

from support import test_main # @UnusedImport
from support import StacklessTestCase, StacklessPickleTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_sched_cb.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import absolute_import
import unittest
import stackless
import gc
import traceback
import sys

from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
1 change: 1 addition & 0 deletions Stackless/unittests/test_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
withThreads = True
except:
withThreads = False
from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_thread.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
# import common

import unittest
Expand All @@ -6,6 +7,7 @@
import time
from stackless import _test_nostacklesscall as apply_not_stackless

from support import test_main # @UnusedImport
from support import StacklessTestCase, AsTaskletTestCase
try:
import threading
Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_tpflags_have_stackless_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
This is a test for issue http://www.stackless.com/ticket/18
"""

from __future__ import absolute_import
import unittest
import stackless
import gc
import sys
from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_tracing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import
import unittest
import stackless
import sys
import inspect
from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_tstate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import absolute_import
import unittest
import sys
from pickle import Pickler, Unpickler
from io import BytesIO
from stackless import *

from support import test_main # @UnusedImport
from support import StacklessTestCase

# import os
Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_watchdog.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import
import sys
import random
import unittest
import stackless

from support import test_main # @UnusedImport
from support import StacklessTestCase, require_one_thread


Expand Down
2 changes: 2 additions & 0 deletions Stackless/unittests/test_weakref.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import
import unittest
import weakref

from stackless import *

from support import test_main # @UnusedImport
from support import StacklessTestCase


Expand Down

0 comments on commit ee7479d

Please sign in to comment.