Merge "tests: Pollute stderr less"
This commit is contained in:
@@ -6342,10 +6342,14 @@ class TestGreenAsyncPile(unittest.TestCase):
|
|||||||
pile.spawn(self._exploder, Exception('kaboom'))
|
pile.spawn(self._exploder, Exception('kaboom'))
|
||||||
self.assertEqual(1, next(pile))
|
self.assertEqual(1, next(pile))
|
||||||
self.assertEqual(2, next(pile))
|
self.assertEqual(2, next(pile))
|
||||||
with self.assertRaises(StopIteration):
|
with mock.patch('sys.stderr', StringIO()) as mock_stderr, \
|
||||||
|
self.assertRaises(StopIteration):
|
||||||
next(pile)
|
next(pile)
|
||||||
self.assertEqual(pile.inflight, 0)
|
self.assertEqual(pile.inflight, 0)
|
||||||
self.assertEqual(pile._pending, 0)
|
self.assertEqual(pile._pending, 0)
|
||||||
|
self.assertIn('Exception: kaboom', mock_stderr.getvalue())
|
||||||
|
self.assertIn('Traceback (most recent call last):',
|
||||||
|
mock_stderr.getvalue())
|
||||||
|
|
||||||
def test_no_blocking_last_next_explodes(self):
|
def test_no_blocking_last_next_explodes(self):
|
||||||
pile = utils.GreenAsyncPile(10)
|
pile = utils.GreenAsyncPile(10)
|
||||||
@@ -6354,13 +6358,18 @@ class TestGreenAsyncPile(unittest.TestCase):
|
|||||||
pile.spawn(self._exploder, 2)
|
pile.spawn(self._exploder, 2)
|
||||||
self.assertEqual(2, next(pile))
|
self.assertEqual(2, next(pile))
|
||||||
pile.spawn(self._exploder, Exception('kaboom'))
|
pile.spawn(self._exploder, Exception('kaboom'))
|
||||||
with self.assertRaises(StopIteration):
|
with mock.patch('sys.stderr', StringIO()) as mock_stderr, \
|
||||||
|
self.assertRaises(StopIteration):
|
||||||
next(pile)
|
next(pile)
|
||||||
self.assertEqual(pile.inflight, 0)
|
self.assertEqual(pile.inflight, 0)
|
||||||
self.assertEqual(pile._pending, 0)
|
self.assertEqual(pile._pending, 0)
|
||||||
|
self.assertIn('Exception: kaboom', mock_stderr.getvalue())
|
||||||
|
self.assertIn('Traceback (most recent call last):',
|
||||||
|
mock_stderr.getvalue())
|
||||||
|
|
||||||
def test_exceptions_in_streaming_pile(self):
|
def test_exceptions_in_streaming_pile(self):
|
||||||
with utils.StreamingPile(2) as pile:
|
with mock.patch('sys.stderr', StringIO()) as mock_stderr, \
|
||||||
|
utils.StreamingPile(2) as pile:
|
||||||
results = list(pile.asyncstarmap(self._exploder, [
|
results = list(pile.asyncstarmap(self._exploder, [
|
||||||
(1,),
|
(1,),
|
||||||
(Exception('kaboom'),),
|
(Exception('kaboom'),),
|
||||||
@@ -6369,9 +6378,13 @@ class TestGreenAsyncPile(unittest.TestCase):
|
|||||||
self.assertEqual(results, [1, 3])
|
self.assertEqual(results, [1, 3])
|
||||||
self.assertEqual(pile.inflight, 0)
|
self.assertEqual(pile.inflight, 0)
|
||||||
self.assertEqual(pile._pending, 0)
|
self.assertEqual(pile._pending, 0)
|
||||||
|
self.assertIn('Exception: kaboom', mock_stderr.getvalue())
|
||||||
|
self.assertIn('Traceback (most recent call last):',
|
||||||
|
mock_stderr.getvalue())
|
||||||
|
|
||||||
def test_exceptions_at_end_of_streaming_pile(self):
|
def test_exceptions_at_end_of_streaming_pile(self):
|
||||||
with utils.StreamingPile(2) as pile:
|
with mock.patch('sys.stderr', StringIO()) as mock_stderr, \
|
||||||
|
utils.StreamingPile(2) as pile:
|
||||||
results = list(pile.asyncstarmap(self._exploder, [
|
results = list(pile.asyncstarmap(self._exploder, [
|
||||||
(1,),
|
(1,),
|
||||||
(2,),
|
(2,),
|
||||||
@@ -6380,6 +6393,9 @@ class TestGreenAsyncPile(unittest.TestCase):
|
|||||||
self.assertEqual(results, [1, 2])
|
self.assertEqual(results, [1, 2])
|
||||||
self.assertEqual(pile.inflight, 0)
|
self.assertEqual(pile.inflight, 0)
|
||||||
self.assertEqual(pile._pending, 0)
|
self.assertEqual(pile._pending, 0)
|
||||||
|
self.assertIn('Exception: kaboom', mock_stderr.getvalue())
|
||||||
|
self.assertIn('Traceback (most recent call last):',
|
||||||
|
mock_stderr.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class TestLRUCache(unittest.TestCase):
|
class TestLRUCache(unittest.TestCase):
|
||||||
|
Reference in New Issue
Block a user