diff options
| author | Sergey Maranchuk <slav0nic@python.su> | 2020-04-17 23:35:37 +0300 |
|---|---|---|
| committer | Sergey Maranchuk <slav0nic@python.su> | 2020-04-19 00:53:36 +0300 |
| commit | aadf19a5b81645b18e50699fe2f180aeff3409b3 (patch) | |
| tree | e8031a2301383f5b5c05fb1a90045842fa3ae296 | |
| parent | 6668e43d2d67db4574e08a9d54bd80eb105c1b28 (diff) | |
| download | pyramid-aadf19a5b81645b18e50699fe2f180aeff3409b3.tar.gz pyramid-aadf19a5b81645b18e50699fe2f180aeff3409b3.tar.bz2 pyramid-aadf19a5b81645b18e50699fe2f180aeff3409b3.zip | |
rename __nonzero__() to __bool__()
| -rw-r--r-- | src/pyramid/registry.py | 6 | ||||
| -rw-r--r-- | src/pyramid/testing.py | 4 | ||||
| -rw-r--r-- | tests/test_registry.py | 8 | ||||
| -rw-r--r-- | tests/test_testing.py | 4 |
4 files changed, 5 insertions, 17 deletions
diff --git a/src/pyramid/registry.py b/src/pyramid/registry.py index 37a39fedb..6f6ef5f77 100644 --- a/src/pyramid/registry.py +++ b/src/pyramid/registry.py @@ -57,7 +57,7 @@ class Registry(Components, dict): def _clear_view_lookup_cache(self): self._view_lookup_cache = {} - def __nonzero__(self): + def __bool__(self): # defeat bool determination via dict.__len__ return True @@ -245,11 +245,9 @@ class Introspectable(dict): self.discriminator, ) - def __nonzero__(self): + def __bool__(self): return True - __bool__ = __nonzero__ # py3 - def register(self, introspector, action_info): self.discriminator = undefer(self.discriminator) self.action_info = action_info diff --git a/src/pyramid/testing.py b/src/pyramid/testing.py index 7c54d7428..8ee9f976c 100644 --- a/src/pyramid/testing.py +++ b/src/pyramid/testing.py @@ -203,11 +203,9 @@ class DummyResource: __iter__ = keys - def __nonzero__(self): + def __bool__(self): return True - __bool__ = __nonzero__ - def __len__(self): return len(self.subs) diff --git a/tests/test_registry.py b/tests/test_registry.py index ce0370468..022cc5ba1 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -11,9 +11,9 @@ class TestRegistry(unittest.TestCase): def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) - def test___nonzero__(self): + def test___bool__(self): registry = self._makeOne() - self.assertEqual(registry.__nonzero__(), True) + self.assertEqual(registry.__bool__(), True) def test__lock(self): registry = self._makeOne() @@ -380,10 +380,6 @@ class TestIntrospectable(unittest.TestCase): "<Introspectable category 'category', discriminator 'discrim'>", ) - def test___nonzero__(self): - inst = self._makeOnePopulated() - self.assertEqual(inst.__nonzero__(), True) - def test___bool__(self): inst = self._makeOnePopulated() self.assertEqual(inst.__bool__(), True) diff --git a/tests/test_testing.py b/tests/test_testing.py index 5273e7f79..e630eb00b 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -103,10 +103,6 @@ class TestDummyResource(unittest.TestCase): self.assertEqual(L(resource.keys()), L(resource.subs.keys())) self.assertEqual(len(resource), 2) - def test_nonzero(self): - resource = self._makeOne() - self.assertEqual(resource.__nonzero__(), True) - def test_bool(self): resource = self._makeOne() self.assertEqual(resource.__bool__(), True) |
