From 82ba1088e98d6e33136b5e78f87ac02d0daa7879 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 30 Nov 2011 13:00:43 -0500 Subject: fix set repr on py3 --- pyramid/tests/test_util.py | 5 ++++- pyramid/util.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pyramid/tests/test_util.py b/pyramid/tests/test_util.py index f45c75535..d010e6653 100644 --- a/pyramid/tests/test_util.py +++ b/pyramid/tests/test_util.py @@ -279,7 +279,10 @@ class Test_object_description(unittest.TestCase): self.assertEqual(self._callFUT(('a', 'b')), "('a', 'b')") def test_set(self): - self.assertEqual(self._callFUT(set(['a'])), "set(['a'])") + if PY3: + self.assertEqual(self._callFUT(set(['a'])), "{'a'}") + else: + self.assertEqual(self._callFUT(set(['a'])), "set(['a'])") def test_list(self): self.assertEqual(self._callFUT(['a']), "['a']") diff --git a/pyramid/util.py b/pyramid/util.py index 1fd612d09..f22f847c4 100644 --- a/pyramid/util.py +++ b/pyramid/util.py @@ -7,6 +7,7 @@ from pyramid.compat import ( integer_types, string_types, text_, + PY3, ) from pyramid.exceptions import ConfigurationError @@ -264,7 +265,12 @@ def object_description(object): return text_(str(object)) if isinstance(object, (bool, float, type(None))): return text_(str(object)) - if isinstance(object, (tuple, set)): + if isinstance(object, set): + if PY3: # pragma: no cover + return shortrepr(object, '}') + else: + return shortrepr(object, ')') + if isinstance(object, tuple): return shortrepr(object, ')') if isinstance(object, list): return shortrepr(object, ']') -- cgit v1.2.3