From 700be1638b21edc60e041554fb10436434ace483 Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Wed, 19 Nov 2025 10:57:50 -0600 Subject: [PATCH 1/3] fix: remove warning for groups without label --- pyxform/xls2json.py | 6 +----- tests/test_fieldlist_labels.py | 37 +++++++++------------------------- tests/test_xlsform_spec.py | 2 -- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/pyxform/xls2json.py b/pyxform/xls2json.py index 335ad049..c1b930df 100644 --- a/pyxform/xls2json.py +++ b/pyxform/xls2json.py @@ -851,11 +851,7 @@ def workbook_to_json( row.get("default") and default_is_dynamic(row.get("default"), question_type) ) - and not ( - control_type is constants.GROUP - and row.get("control", {}).get("appearance") - == constants.FIELD_LIST - ) + and (control_type is not constants.GROUP) ): # Row number, name, and type probably enough for user message. # Also means the error message text is stable for tests. diff --git a/tests/test_fieldlist_labels.py b/tests/test_fieldlist_labels.py index a824791d..4b11f1e7 100644 --- a/tests/test_fieldlist_labels.py +++ b/tests/test_fieldlist_labels.py @@ -17,8 +17,14 @@ def test_unlabeled_group(self): | | text | my-text | my-text | | | end_group | | | """, - warnings_count=1, - warnings__contains=["[row : 2] Group has no label"], + warnings_count=0, + xml__xpath_match=[ + """ + /h:html/h:body/x:group[ + @ref = '/test_name/my-group' + ] + """ + ], ) def test_unlabeled_group_alternate_syntax(self): @@ -30,41 +36,16 @@ def test_unlabeled_group_alternate_syntax(self): | | text | my-text | my-text | | | end group | | | """, - warnings_count=1, - warnings__contains=["[row : 2] Group has no label"], - ) - - def test_unlabeled_group_fieldlist(self): - self.assertPyxformXform( - md=""" - | survey | | | | | - | | type | name | label | appearance | - | | begin_group | my-group | | field-list | - | | text | my-text | my-text | | - | | end_group | | | | - """, warnings_count=0, xml__xpath_match=[ """ /h:html/h:body/x:group[ - @ref = '/test_name/my-group' and @appearance='field-list' + @ref = '/test_name/my-group' ] """ ], ) - def test_unlabeled_group_fieldlist_alternate_syntax(self): - self.assertPyxformXform( - md=""" - | survey | | | | | - | | type | name | label | appearance | - | | begin group | my-group | | field-list | - | | text | my-text | my-text | | - | | end group | | | | - """, - warnings_count=0, - ) - def test_unlabeled_repeat(self): self.assertPyxformXform( md=""" diff --git a/tests/test_xlsform_spec.py b/tests/test_xlsform_spec.py index 891c591b..cbebed6a 100644 --- a/tests/test_xlsform_spec.py +++ b/tests/test_xlsform_spec.py @@ -68,8 +68,6 @@ def test_warnings__count(self): vc.INVALID_LABEL.format(row=6), vc.INVALID_LABEL.format(row=7), "[row : 9] Repeat has no label: {'name': 'repeat_test', 'type': 'begin repeat'}", - "[row : 10] Group has no label: {'name': 'group_test', 'type': 'begin group'}", - "[row : 17] Group has no label: {'name': 'name', 'type': 'begin group'}", "[row : 28] Use the max-pixels parameter to speed up submission " + "sending and save storage space. Learn more: https://xlsform.org/#image", ] From dd3ef681fe5b0ea1a0d0663567c3ef8cd44f9159 Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Thu, 18 Dec 2025 07:46:17 -0600 Subject: [PATCH 2/3] Update refactored tests --- tests/test_group.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/tests/test_group.py b/tests/test_group.py index afec55f2..bc130db2 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -652,8 +652,14 @@ def test_unlabeled_group(self): | | text | my-text | my-text | | | end_group | | | """, - warnings_count=1, - warnings__contains=["[row : 2] Group has no label"], + warnings_count=0, + xml__xpath_match=[ + """ + /h:html/h:body/x:group[ + @ref = '/test_name/my-group' + ] + """ + ], ) def test_unlabeled_group_alternate_syntax(self): @@ -665,42 +671,16 @@ def test_unlabeled_group_alternate_syntax(self): | | text | my-text | my-text | | | end group | | | """, - warnings_count=1, - warnings__contains=["[row : 2] Group has no label"], - ) - - def test_unlabeled_group_fieldlist(self): - self.assertPyxformXform( - md=""" - | survey | - | | type | name | label | appearance | - | | begin_group | my-group | | field-list | - | | text | my-text | my-text | | - | | end_group | | | | - """, warnings_count=0, xml__xpath_match=[ """ /h:html/h:body/x:group[ - @ref = '/test_name/my-group' and @appearance='field-list' + @ref = '/test_name/my-group' ] """ ], ) - def test_unlabeled_group_fieldlist_alternate_syntax(self): - self.assertPyxformXform( - md=""" - | survey | - | | type | name | label::English (en) | appearance | - | | begin group | my-group | | field-list | - | | text | my-text | my-text | | - | | end group | | | | - """, - warnings_count=0, - ) - - class TestGroupInternalRepresentations(TestCase): maxDiff = None From 00dea8dbc65ba9af451947565e3bc85eecb44540 Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Thu, 18 Dec 2025 09:01:14 -0600 Subject: [PATCH 3/3] Fix linting --- tests/test_group.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_group.py b/tests/test_group.py index bc130db2..45978af7 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -681,6 +681,7 @@ def test_unlabeled_group_alternate_syntax(self): ], ) + class TestGroupInternalRepresentations(TestCase): maxDiff = None