]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
ValueList cannot actually contain another ValueList
authorHenryk Plötz <henryk@ploetzli.ch>
Thu, 9 Aug 2018 22:05:15 +0000 (00:05 +0200)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:34:17 +0000 (19:34 +0100)
fints/formals.py
tests/test_formals.py

index 4e34f9b53195dbeddc645fbbebd62191cec7fa75..4e38232f0a785eb8e5b4912b79250d650f2a2b52 100644 (file)
@@ -56,9 +56,6 @@ class ValueList:
                 if isinstance(val, Container):
                     if val.is_unset():
                         continue
-                elif isinstance(val, ValueList):
-                    if len(val) == 0:
-                        continue
                 elif val is None:
                     continue
                 retval = i+1
@@ -161,7 +158,7 @@ class Field:
     def render(self, value):
         if value is None:
             return ""
-        
+
         return self._render_value(value)
 
 class TypedField(Field, SubclassesMixin):
index 19b876227c96b266d0cfd771a2c685959b510c2b..0b9cdeebf512afccf3ac4f61e40bbd4d94313f10 100644 (file)
@@ -298,6 +298,23 @@ def test_sequence_repr():
 
     assert repr(s) == 'SegmentSequence([])'
 
+def test_valuelist_repr():
+    class A(Container):
+        a = NumericField(max_count=3)
+
+    i1 = A()
+    assert repr(i1.a) == "[]"
+
+def test_empty_list():
+    class A(Container):
+        a = NumericField(max_count=3)
+
+    i1 = A()
+    assert len(i1.a) == 0
+
+    i2 = A(a=[None])
+    assert len(i2.a) == 0
+
 def test_segmentheader_short():
     h = SegmentHeader('HNHBS', 5, 1)