XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

Circular reference error raised when converting an XLSX form with multiple languages to JSON #513

Closed DavisRayM closed 3 years ago

DavisRayM commented 3 years ago

Software and hardware versions

pyxform v1.3.4

Problem description

The error ValueError: Circular reference detected is raised when trying to convert an XLSForm with multiple languages to JSON after running the to_xml function.

Steps to reproduce the problem

XLSForm

from pyxform.tests_v1.pyxform_test_case import PyxformTestCase

class TestConvertSurveyToJSON(PyxformTestCase):
    def test_able_to_convert_to_JSON(self):
        md = """
        | survey  |
        |         | type                   | name  | label:Eng  | label:Fr |
        |         | text                   | name  | Name       | Prénom   |
        |         | select_multiple fruits | fruit | Fruit      | Fruit    |
        |         |                        |       |            |          |
        | choices | list name              | name  | label:Eng  | label:Fr |
        |         | fruits                 | 1     | Mango      | Mangue   |
        |         | fruits                 | 2     | Orange     | Orange   |
        |         | fruits                 | 3     | Apple      | Pomme    |
        """

        survey = self.md_to_pyxform_survey(
            md_raw=md,
            kwargs={"id_string": "id", "name": "multi-language", "title": "some-title"},
            autoname=False,
        )
        survey.to_xml()
        survey.to_json()

Expected behavior

Forms with multiple languages should be converted to JSON correctly.

Other information

Stack trace:

Screenshot 2021-01-26 at 12 42 29 PM

_Tried removing the _translations key and that seemed to fix the Circular import error; I believe the parent keys in the _translations dict may be raising the error._ Things you tried, stack traces, related issues, suggestions on how to fix it...