Skip to content

Commit

Permalink
backport master fix from #1032 to 1.4-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Jul 16, 2013
1 parent dc2c354 commit b54f6d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Next 1.4 release
================

- ``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.2 (2013-05-21)
==================

Expand Down
3 changes: 3 additions & 0 deletions pyramid/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def keys(self):

__iter__ = keys

def __bool__(self):
return True

def __nonzero__(self):
return True

Expand Down
4 changes: 4 additions & 0 deletions pyramid/tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b54f6d7

Please sign in to comment.