Skip to content

Conversation

@lindsay-stevens
Copy link
Contributor

Closes #754

Also added test to document behaviour with repeats where a similar 'empty group' error is not raised
Also tidies up group/repeat related tests to make test coverage clearer

Why is this the best possible solution? Were any other approaches considered?

In section.py, considered adding if self.children is not None branches where necessary, but usually a Section subclass will have child elements so instead a default list is created in the __init__ method.

What are the regression risks?

If an external library subclasses SurveyElement but expects the moved children-related methods to be there, they would need to copy them over to their own implementation, or use Section as a parent class instead.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No just a bug fix.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run python -m unittest and verified all tests pass
  • run ruff format pyxform tests and ruff check pyxform tests to lint code
  • verified that any code or assets from external sources are properly credited in comments

- groups usually have child elements, and if they don't (as shown in
  test_groups.py) ODK Validate will raise an error, so the Section
  class now sets a default list since most of the time a list will be
  created anyway. Moved children-related class methods from
  SurveyElement to Section since the latter is the type using them.
- interestingly the same kind of error does not occur for repeats,
  as shown in test_repeat.py.
- empty groups may also be a problem in form clients as follows but
  this behaviour can't be tested here:
  - enketo with setting `style` = `theme-grid` but no group label
  - collect group with no visible items due to all being relevant=false
- while it makes the git history a little harder to navigate, this
  should make it easier to understand test coverage for these elements
- there's no empty group error expected for repeats but in any case an
  error can't be raised by validate if it's not run on the xform
@lognaturel
Copy link
Contributor

Thanks!

@lognaturel lognaturel merged commit c2bf6bc into XLSForm:master Dec 9, 2025
14 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-754 branch December 9, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing XLSForm with empty group results in confusing error

2 participants