Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- ``pyramid.testing.DummyResource`` didn't define ``__bool__``, so co…

…de under

   Python 3 would use ``__len__`` to find truthiness; this usually caused an
   instance of DummyResource to be "falsy" instead of "truthy".  See
   #1032

Closes #1032
  • Loading branch information...
commit 050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0 1 parent 035b860
@mcdonc mcdonc authored
View
5 CHANGES.txt
@@ -111,6 +111,11 @@ Bug Fixes
files have now been removed. See
https://github.com/Pylons/pyramid/issues/981
+- ``pyramid.testing.DummyResource`` didn't define ``__bool__``, so code under
+ Python 3 would use ``__len__`` to find truthiness; this usually caused an
+ instance of DummyResource to be "falsy" instead of "truthy". See
+ https://github.com/Pylons/pyramid/pull/1032
+
1.4 (2012-12-18)
================
View
2  pyramid/testing.py
@@ -222,6 +222,8 @@ def keys(self):
def __nonzero__(self):
return True
+ __bool__ = __nonzero__
+
def __len__(self):
return len(self.subs)
View
4 pyramid/tests/test_testing.py
@@ -114,6 +114,10 @@ def test_nonzero(self):
resource = self._makeOne()
self.assertEqual(resource.__nonzero__(), True)
+ def test_bool(self):
+ resource = self._makeOne()
+ self.assertEqual(resource.__bool__(), True)
+
def test_ctor_with__provides__(self):
resource = self._makeOne(__provides__=IDummy)
self.assertTrue(IDummy.providedBy(resource))
Please sign in to comment.
Something went wrong with that request. Please try again.