Просмотр исходного кода

Removes irrelevant test output

Ask Solem 11 лет назад
Родитель
Сommit
05f9d18376

+ 2 - 7
celery/tests/app/test_loaders.py

@@ -7,7 +7,6 @@ import warnings
 from celery import loaders
 from celery.exceptions import (
     NotConfigured,
-    CPendingDeprecationWarning,
 )
 from celery.loaders import base
 from celery.loaders import default
@@ -34,16 +33,12 @@ class test_loaders(AppCase):
 
     @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)
 
 

+ 5 - 9
celery/tests/backends/test_redis.py

@@ -10,7 +10,7 @@ from celery import signature
 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 @@ class test_RedisBackend(AppCase):
         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):

+ 13 - 0
celery/tests/case.py

@@ -37,6 +37,7 @@ from kombu.utils import nested, symbol_by_name
 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 @@ class Case(unittest.TestCase):
         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 = [], []
 

+ 22 - 14
celery/tests/tasks/test_result.py

@@ -311,17 +311,19 @@ class test_ResultSet(AppCase):
         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 @@ class test_ResultSet(AppCase):
         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 @@ class test_GroupResult(AppCase):
     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,7 +534,8 @@ class test_GroupResult(AppCase):
         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)
 
@@ -538,7 +543,8 @@ class test_GroupResult(AppCase):
         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 @@ class test_GroupResult(AppCase):
         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 @@ class test_failed_AsyncResult(test_GroupResult):
         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)

+ 3 - 2
celery/tests/utils/test_datastructures.py

@@ -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 @@ class test_LimitedSet(Case):
         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:

+ 4 - 2
celery/tests/utils/test_platforms.py

@@ -416,8 +416,10 @@ if not platforms.IS_WINDOWS:
             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')

+ 1 - 1
requirements/test-ci.txt

@@ -3,4 +3,4 @@ coveralls
 redis
 #pymongo
 #SQLAlchemy
-#PyOpenSSL
+PyOpenSSL