This patch ensures that Unset objects are false in boolean context

Signed-off-by: Zygmunt Krynicki <[email protected]>
---
 plainbox/plainbox/impl/secure/config.py      | 3 +++
 plainbox/plainbox/impl/secure/test_config.py | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/plainbox/plainbox/impl/secure/config.py 
b/plainbox/plainbox/impl/secure/config.py
index 1b4d1f2..7e8f87f 100644
--- a/plainbox/plainbox/impl/secure/config.py
+++ b/plainbox/plainbox/impl/secure/config.py
@@ -89,6 +89,9 @@ class UnsetType:
     def __repr__(self):
         return "Unset"
 
+    def __bool__(self):
+        return False
+
 
 Unset = UnsetType()
 
diff --git a/plainbox/plainbox/impl/secure/test_config.py 
b/plainbox/plainbox/impl/secure/test_config.py
index e00815d..e1ce0dd 100644
--- a/plainbox/plainbox/impl/secure/test_config.py
+++ b/plainbox/plainbox/impl/secure/test_config.py
@@ -46,6 +46,9 @@ class UnsetTests(TestCase):
     def test_repr(self):
         self.assertEqual(repr(Unset), "Unset")
 
+    def test_bool(self):
+        self.assertEqual(bool(Unset), False)
+
 
 class understands_Unset_Tests(TestCase):
 
-- 
1.9.0


-- 
Mailing list: https://launchpad.net/~checkbox-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~checkbox-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to