diff --git a/pyxform/tests_v1/test_choices_sheet.py b/pyxform/tests_v1/test_choices_sheet.py
new file mode 100644
index 00000000..d3a373c8
--- /dev/null
+++ b/pyxform/tests_v1/test_choices_sheet.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+from pyxform.tests_v1.pyxform_test_case import PyxformTestCase
+from pyxform.utils import unicode
+
+
+class ChoicesSheetTest(PyxformTestCase):
+ def test_numeric_choice_names__for_static_selects__allowed(self):
+ """
+ Test numeric choice names for static selects.
+ """
+ self.assertPyxformXform(
+ md="""
+ | survey | | | |
+ | | type | name | label |
+ | | select_one choices | a | A |
+ | choices | | | |
+ | | list_name | name | label |
+ | | choices | 1 | One |
+ | | choices | 2 | Two |
+ """,
+ xml__contains=["1"],
+ )
+
+ def test_numeric_choice_names__for_dynamic_selects__allowed(self):
+ """
+ Test numeric choice names for dynamic selects.
+ """
+ self.assertPyxformXform(
+ md="""
+ | survey | | | | |
+ | | type | name | label | choice_filter |
+ | | select_one choices | a | A | true() |
+ | choices | | | |
+ | | list_name | name | label |
+ | | choices | 1 | One |
+ | | choices | 2 | Two |
+ """,
+ xml__contains=['', "- ", "1"],
+ )
+
+ def test_choices_without_labels__for_static_selects__allowed(self):
+ """
+ Test choices without labels for static selects. Validate will NOT fail.
+ """
+ self.assertPyxformXform(
+ md="""
+ | survey | | | |
+ | | type | name | label |
+ | | select_one choices | a | A |
+ | choices | | | |
+ | | list_name | name | label |
+ | | choices | 1 | |
+ | | choices | 2 | |
+ """,
+ xml__contains=["1"],
+ )
+
+ def test_choices_without_labels__for_dynamic_selects__allowed_by_pyxform(self):
+ """
+ Test choices without labels for dynamic selects. Validate will fail.
+ """
+ self.assertPyxformXform(
+ md="""
+ | survey | | | | |
+ | | type | name | label | choice_filter |
+ | | select_one choices | a | A | true() |
+ | choices | | | |
+ | | list_name | name | label |
+ | | choices | 1 | |
+ | | choices | 2 | |
+ """,
+ run_odk_validate=False,
+ xml__contains=['', "
- ", "1"],
+ )
diff --git a/pyxform/utils.py b/pyxform/utils.py
index 58225cee..afc6778d 100644
--- a/pyxform/utils.py
+++ b/pyxform/utils.py
@@ -277,6 +277,10 @@ def default_is_dynamic(element_default, element_type=None):
def has_dynamic_label(choice_list, multi_language):
if not multi_language:
for i in range(0, min(2, len(choice_list))):
- if re.search(BRACKETED_TAG_REGEX, choice_list[i].get("label")) is not None:
+ if (
+ choice_list[i].get("label") is not None
+ and re.search(BRACKETED_TAG_REGEX, choice_list[i].get("label"))
+ is not None
+ ):
return True
return False