Commits

Jonathan Eunice  committed b29eea6

fixed bug in nulltype

  • Participants
  • Parent commits 2e8b43c

Comments (0)

Files changed (3)

File options/nulltype.py

             return self.name
         else:
             return repr(self)
-        
+
+    
     if _PY3:
-        def bool(self):
+        def __bool__(self):
             """I am always False."""
             return False
-    else:
+    else: # PY2
         def __nonzero__(self):
             """I am always False."""
             return False
 
 setup(
     name='options',
-    version=verno("0.420"),
+    version=verno("0.425"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Container for flexible class, instance, and function call options',

File test/test_nulltype.py

+
+from options.nulltype import *
+
+### Setup
+
+Prohibited = NullType("Prohibited")
+Transient  = NullType("Transient")
+Nothing    = NullType("Nothing")
+
+nulls = [Prohibited, Transient, Nothing] 
+
+### Tests
+
+def test_bool():
+    for n in nulls:
+        assert not bool(n)
+
+def test_if():
+    for n in nulls:
+        if n:
+            assert False