Commit bee87cfd authored by Jason Madden's avatar Jason Madden

Enable warnings when running our tests. Rename (the undocumented)...

Enable warnings when running our tests. Rename (the undocumented) threadpool.ThreadResult.async to async_watcher because it's a keyword in 3.7, as exposed by warnings.
parent 08368c0b
...@@ -267,7 +267,7 @@ class ThreadPool(GroupMappingMixin): ...@@ -267,7 +267,7 @@ class ThreadPool(GroupMappingMixin):
class ThreadResult(object): class ThreadResult(object):
# Using slots here helps to debug reference cycles/leaks # Using slots here helps to debug reference cycles/leaks
__slots__ = ('exc_info', 'async', '_call_when_ready', 'value', __slots__ = ('exc_info', 'async_watcher', '_call_when_ready', 'value',
'context', 'hub', 'receiver') 'context', 'hub', 'receiver')
def __init__(self, receiver, hub=None, call_when_ready=None): def __init__(self, receiver, hub=None, call_when_ready=None):
...@@ -278,16 +278,16 @@ class ThreadResult(object): ...@@ -278,16 +278,16 @@ class ThreadResult(object):
self.context = None self.context = None
self.value = None self.value = None
self.exc_info = () self.exc_info = ()
self.async = hub.loop.async() self.async_watcher = hub.loop.async()
self._call_when_ready = call_when_ready self._call_when_ready = call_when_ready
self.async.start(self._on_async) self.async_watcher.start(self._on_async)
@property @property
def exception(self): def exception(self):
return self.exc_info[1] if self.exc_info else None return self.exc_info[1] if self.exc_info else None
def _on_async(self): def _on_async(self):
self.async.stop() self.async_watcher.stop()
if self._call_when_ready: if self._call_when_ready:
# Typically this is pool.semaphore.release and we have to # Typically this is pool.semaphore.release and we have to
# call this in the Hub; if we don't we get the dreaded # call this in the Hub; if we don't we get the dreaded
...@@ -297,7 +297,7 @@ class ThreadResult(object): ...@@ -297,7 +297,7 @@ class ThreadResult(object):
if self.exc_info: if self.exc_info:
self.hub.handle_error(self.context, *self.exc_info) self.hub.handle_error(self.context, *self.exc_info)
self.context = None self.context = None
self.async = None self.async_watcher = None
self.hub = None self.hub = None
self._call_when_ready = None self._call_when_ready = None
if self.receiver is not None: if self.receiver is not None:
...@@ -309,17 +309,17 @@ class ThreadResult(object): ...@@ -309,17 +309,17 @@ class ThreadResult(object):
self.exc_info = (self.exc_info[0], self.exc_info[1], None) self.exc_info = (self.exc_info[0], self.exc_info[1], None)
def destroy(self): def destroy(self):
if self.async is not None: if self.async_watcher is not None:
self.async.stop() self.async_watcher.stop()
self.async = None self.async_watcher = None
self.context = None self.context = None
self.hub = None self.hub = None
self._call_when_ready = None self._call_when_ready = None
self.receiver = None self.receiver = None
def _ready(self): def _ready(self):
if self.async is not None: if self.async_watcher is not None:
self.async.send() self.async_watcher.send()
def set(self, value): def set(self, value):
self.value = value self.value = value
......
...@@ -413,6 +413,21 @@ class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})): ...@@ -413,6 +413,21 @@ class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})):
del self.close_on_teardown del self.close_on_teardown
except AttributeError: except AttributeError:
pass pass
super(TestCase, self).tearDown()
@classmethod
def setUpClass(cls):
import warnings
cls._warning_cm = warnings.catch_warnings()
cls._warning_cm.__enter__()
if not sys.warnoptions:
warnings.simplefilter('default')
super(TestCase, cls).setUpClass()
@classmethod
def tearDownClass(cls):
cls._warning_cm.__exit__(None, None, None)
super(TestCase, cls).tearDownClass()
def _close_on_teardown(self, resource): def _close_on_teardown(self, resource):
if 'close_on_teardown' not in self.__dict__: if 'close_on_teardown' not in self.__dict__:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment