Permalink
Browse files

Removes irrelevant test output

  • Loading branch information...
1 parent f573078 commit 05f9d18376beff343e2dca6dc20cd7d97df8c74b @ask ask committed Feb 10, 2014
@@ -7,7 +7,6 @@
from celery import loaders
from celery.exceptions import (
NotConfigured,
- CPendingDeprecationWarning,
)
from celery.loaders import base
from celery.loaders import default
@@ -34,16 +33,12 @@ def test_get_loader_cls(self):
@depends_on_current_app
def test_current_loader(self):
- with self.assertWarnsRegex(
- CPendingDeprecationWarning,
- r'deprecation'):
+ with self.assertPendingDeprecation():
self.assertIs(loaders.current_loader(), self.app.loader)
@depends_on_current_app
def test_load_settings(self):
- with self.assertWarnsRegex(
- CPendingDeprecationWarning,
- r'deprecation'):
+ with self.assertPendingDeprecation():
self.assertIs(loaders.load_settings(), self.app.conf)
@@ -10,7 +10,7 @@
from celery import states
from celery import group
from celery.datastructures import AttributeDict
-from celery.exceptions import CPendingDeprecationWarning, ImproperlyConfigured
+from celery.exceptions import ImproperlyConfigured
from celery.utils.timeutils import timedelta_seconds
from celery.tests.case import (
@@ -151,17 +151,13 @@ def test_compat_propertie(self):
x = self.MockBackend(
'redis://:bosco@vandelay.com:123//1', app=self.app,
)
- with self.assertWarnsRegex(CPendingDeprecationWarning,
- r'scheduled for deprecation'):
+ with self.assertPendingDeprecation():
self.assertEqual(x.host, 'vandelay.com')
- with self.assertWarnsRegex(CPendingDeprecationWarning,
- r'scheduled for deprecation'):
+ with self.assertPendingDeprecation():
self.assertEqual(x.db, 1)
- with self.assertWarnsRegex(CPendingDeprecationWarning,
- r'scheduled for deprecation'):
+ with self.assertPendingDeprecation():
self.assertEqual(x.port, 123)
- with self.assertWarnsRegex(CPendingDeprecationWarning,
- r'scheduled for deprecation'):
+ with self.assertPendingDeprecation():
self.assertEqual(x.password, 'bosco')
def test_conf_raises_KeyError(self):
View
@@ -37,6 +37,7 @@
from celery import Celery
from celery.app import current_app
from celery.backends.cache import CacheBackend, DummyClient
+from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning
from celery.five import (
WhateverIO, builtins, items, reraise,
string_t, values, open_fqdn,
@@ -262,6 +263,18 @@ def assertWarnsRegex(self, expected_warning, expected_regex):
return _AssertWarnsContext(expected_warning, self,
None, expected_regex)
+ @contextmanager
+ def assertDeprecated(self):
+ with self.assertWarnsRegex(CDeprecationWarning,
+ r'scheduled for removal'):
+ yield
+
+ @contextmanager
+ def assertPendingDeprecation(self):
+ with self.assertWarnsRegex(CPendingDeprecationWarning,
+ r'scheduled for deprecation'):
+ yield
+
def assertDictContainsSubset(self, expected, actual, msg=None):
missing, mismatched = [], []
@@ -311,17 +311,19 @@ def se(*args, **kwargs):
x = self.app.ResultSet([r1, r2])
with self.dummy_copy():
with patch('celery.result.time') as _time:
- with self.assertRaises(KeyError):
- list(x.iterate())
+ with self.assertPendingDeprecation():
+ with self.assertRaises(KeyError):
+ list(x.iterate())
_time.sleep.assert_called_with(10)
backend.subpolling_interval = 0
with patch('celery.result.time') as _time:
- with self.assertRaises(KeyError):
- ready.return_value = False
- ready.side_effect = se
- list(x.iterate())
- self.assertFalse(_time.sleep.called)
+ with self.assertPendingDeprecation():
+ with self.assertRaises(KeyError):
+ ready.return_value = False
+ ready.side_effect = se
+ list(x.iterate())
+ self.assertFalse(_time.sleep.called)
def test_times_out(self):
r1 = self.app.AsyncResult(uuid)
@@ -330,8 +332,9 @@ def test_times_out(self):
x = self.app.ResultSet([r1])
with self.dummy_copy():
with patch('celery.result.time'):
- with self.assertRaises(TimeoutError):
- list(x.iterate(timeout=1))
+ with self.assertPendingDeprecation():
+ with self.assertRaises(TimeoutError):
+ list(x.iterate(timeout=1))
def test_add_discard(self):
x = self.app.ResultSet([])
@@ -449,7 +452,8 @@ def test_reduce(self):
def test_iterate_raises(self):
ar = MockAsyncResultFailure(uuid(), app=self.app)
ts = self.app.GroupResult(uuid(), [ar])
- it = ts.iterate()
+ with self.assertPendingDeprecation():
+ it = ts.iterate()
with self.assertRaises(KeyError):
next(it)
@@ -530,15 +534,17 @@ def test_iterate_yields(self):
ar = MockAsyncResultSuccess(uuid(), app=self.app)
ar2 = MockAsyncResultSuccess(uuid(), app=self.app)
ts = self.app.GroupResult(uuid(), [ar, ar2])
- it = ts.iterate()
+ with self.assertPendingDeprecation():
+ it = ts.iterate()
self.assertEqual(next(it), 42)
self.assertEqual(next(it), 42)
def test_iterate_eager(self):
ar1 = EagerResult(uuid(), 42, states.SUCCESS)
ar2 = EagerResult(uuid(), 42, states.SUCCESS)
ts = self.app.GroupResult(uuid(), [ar1, ar2])
- it = ts.iterate()
+ with self.assertPendingDeprecation():
+ it = ts.iterate()
self.assertEqual(next(it), 42)
self.assertEqual(next(it), 42)
@@ -560,7 +566,8 @@ def test_iter_native_when_empty_group(self):
self.assertListEqual(list(ts.iter_native()), [])
def test_iterate_simple(self):
- it = self.ts.iterate()
+ with self.assertPendingDeprecation():
+ it = self.ts.iterate()
results = sorted(list(it))
self.assertListEqual(results, list(range(self.size)))
@@ -610,7 +617,8 @@ def test_completed_count(self):
self.assertEqual(self.ts.completed_count(), len(self.ts) - 1)
def test_iterate_simple(self):
- it = self.ts.iterate()
+ with self.assertPendingDeprecation():
+ it = self.ts.iterate()
def consume():
return list(it)
@@ -170,7 +170,7 @@ class test_LimitedSet(Case):
def setUp(self):
if sys.platform == 'win32':
- raise SkipTest('Not working in Windows')
+ raise SkipTest('Not working on Windows')
def test_add(self):
if sys.platform == 'win32':
@@ -231,7 +231,8 @@ def test_pickleable(self):
self.assertEqual(pickle.loads(pickle.dumps(s)), s)
def test_iter(self):
- raise SkipTest('Not working on Windows')
+ if sys.platform == 'win32':
+ raise SkipTest('Not working on Windows')
s = LimitedSet(maxlen=3)
items = ['foo', 'bar', 'baz', 'xaz']
for item in items:
@@ -416,8 +416,10 @@ def test_create_pidlock(self, Pidfile):
p = Pidfile.return_value = Mock()
p.is_locked.return_value = True
p.remove_if_stale.return_value = False
- with self.assertRaises(SystemExit):
- create_pidlock('/var/pid')
+ with override_stdouts() as (_, err):
+ with self.assertRaises(SystemExit):
+ create_pidlock('/var/pid')
+ self.assertIn('already exists', err.getvalue())
p.remove_if_stale.return_value = True
ret = create_pidlock('/var/pid')
View
@@ -3,4 +3,4 @@ coveralls
redis
#pymongo
#SQLAlchemy
-#PyOpenSSL
+PyOpenSSL

0 comments on commit 05f9d18

Please sign in to comment.