ソースを参照

classex.AttributeDescriptor: ignoring min filter if 0 fixed

Fabian Peter Hammerle 8 年 前
コミット
ce01e4affb
2 ファイル変更3 行追加3 行削除
  1. 1 1
      ioex/classex.py
  2. 2 2
      tests/classex/test_attribute_descriptor.py

+ 1 - 1
ioex/classex.py

@@ -18,7 +18,7 @@ class AttributeDescriptor(object):
                 type(value).__name__,
                 value,
             ))
-        elif self._min and not self._min <= value:
+        elif self._min is not None and not self._min <= value:
             raise ValueError('expected value >= {!r}, {!r} given'.format(
                 self._min,
                 value,

+ 2 - 2
tests/classex/test_attribute_descriptor.py

@@ -101,7 +101,7 @@ def test_types():
 
 class MinFilter(object):
 
-    desc = AttributeDescriptor('attr', types=(int,), min=2)
+    desc = AttributeDescriptor('attr', types=(int,), min=0)
 
 
 def test_min():
@@ -111,4 +111,4 @@ def test_min():
     obj.attr = 1
     assert 1 == obj.desc
     with pytest.raises(ValueError):
-        obj.desc = 0
+        obj.desc = -1