소스 검색

Add nodes names to DuplicateNodenameWarning

DuplicateNodenameWarning didn't have a list of duplicates included
into the warning text.
Sebastian Kalinowski 9 년 전
부모
커밋
3626b4c9b8
2개의 변경된 파일10개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 1
      celery/app/control.py
  2. 9 7
      celery/tests/app/test_control.py

+ 1 - 1
celery/app/control.py

@@ -23,7 +23,7 @@ from celery.utils.text import pluralize
 __all__ = ['Inspect', 'Control', 'flatten_reply']
 __all__ = ['Inspect', 'Control', 'flatten_reply']
 
 
 W_DUPNODE = """\
 W_DUPNODE = """\
-Received multiple replies from node name: {0!r}.
+Received multiple replies from node {0}: {1}.
 Please make sure you give each node a unique nodename using the `-n` option.\
 Please make sure you give each node a unique nodename using the `-n` option.\
 """
 """
 
 

+ 9 - 7
celery/tests/app/test_control.py

@@ -7,6 +7,7 @@ from functools import wraps
 from kombu.pidbox import Mailbox
 from kombu.pidbox import Mailbox
 
 
 from celery.app import control
 from celery.app import control
+from celery.exceptions import DuplicateNodenameWarning
 from celery.utils import uuid
 from celery.utils import uuid
 from celery.tests.case import AppCase
 from celery.tests.case import AppCase
 
 
@@ -48,14 +49,15 @@ class test_flatten_reply(AppCase):
             {'foo@example.com': {'hello': 20}},
             {'foo@example.com': {'hello': 20}},
             {'bar@example.com': {'hello': 30}}
             {'bar@example.com': {'hello': 30}}
         ]
         ]
-        with warnings.catch_warnings(record=True) as w:
+        with self.assertWarns(DuplicateNodenameWarning) as w:
             nodes = control.flatten_reply(reply)
             nodes = control.flatten_reply(reply)
-            self.assertIn(
-                'multiple replies',
-                str(w[-1].message),
-            )
-            self.assertIn('foo@example.com', nodes)
-            self.assertIn('bar@example.com', nodes)
+
+        self.assertIn(
+            'Received multiple replies from node name: foo@example.com.',
+            str(w.warning)
+        )
+        self.assertIn('foo@example.com', nodes)
+        self.assertIn('bar@example.com', nodes)
 
 
 
 
 class test_inspect(AppCase):
 class test_inspect(AppCase):