diff options
| author | Chris McDonough <chrism@plope.com> | 2013-06-11 13:19:16 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2013-06-11 13:19:16 -0400 |
| commit | 050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0 (patch) | |
| tree | 14411c9a227a639fd71b15e2c1bc019faa233805 | |
| parent | 035b86007d950d2b229e92e421369c50e99bdf9a (diff) | |
| download | pyramid-050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0.tar.gz pyramid-050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0.tar.bz2 pyramid-050b71c19081d95c1fb8ed57a87fab7fa4dd3ab0.zip | |
- ``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
Closes #1032
| -rw-r--r-- | CHANGES.txt | 5 | ||||
| -rw-r--r-- | pyramid/testing.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_testing.py | 4 |
3 files changed, 11 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 6a26879a3..2c8c6ee46 100644 --- a/CHANGES.txt +++ b/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) ================ diff --git a/pyramid/testing.py b/pyramid/testing.py index 06b795f9a..9bd245e4e 100644 --- a/pyramid/testing.py +++ b/pyramid/testing.py @@ -222,6 +222,8 @@ class DummyResource: def __nonzero__(self): return True + __bool__ = __nonzero__ + def __len__(self): return len(self.subs) diff --git a/pyramid/tests/test_testing.py b/pyramid/tests/test_testing.py index 7f14462a2..da57c6301 100644 --- a/pyramid/tests/test_testing.py +++ b/pyramid/tests/test_testing.py @@ -114,6 +114,10 @@ class TestDummyResource(unittest.TestCase): 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)) |
