From: Henryk Plötz Date: Thu, 9 Aug 2018 22:05:15 +0000 (+0200) Subject: ValueList cannot actually contain another ValueList X-Git-Tag: v2.0.0~1^2~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8610c88d963fe80dd05a43ede9e5b928b15af90;p=thirdparty%2Fpython-fints.git ValueList cannot actually contain another ValueList --- diff --git a/fints/formals.py b/fints/formals.py index 4e34f9b..4e38232 100644 --- a/fints/formals.py +++ b/fints/formals.py @@ -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): diff --git a/tests/test_formals.py b/tests/test_formals.py index 19b8762..0b9cdee 100644 --- a/tests/test_formals.py +++ b/tests/test_formals.py @@ -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)