quizcomp.parser.parse_parsertest

  1import glob
  2import os
  3import re
  4import typing
  5
  6import edq.util.json
  7import edq.util.serial
  8
  9import quizcomp.model.constants
 10import quizcomp.parser.common
 11import quizcomp.parser.document
 12import quizcomp.testing.base
 13import quizcomp.util.html
 14
 15THIS_DIR: str = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
 16TESTDATA_DIR: str = os.path.join(THIS_DIR, 'testdata')
 17
 18DOCUMENTS_DIR = os.path.join(TESTDATA_DIR, 'documents')
 19GOOD_DOCUMENTS_DIR = os.path.join(DOCUMENTS_DIR, "good")
 20BAD_DOCUMENTS_DIR = os.path.join(DOCUMENTS_DIR, "bad")
 21
 22class TestParser(quizcomp.testing.base.BaseTest):
 23    """
 24    Test parsing text.
 25    Good and bad situations will be loaded from files into individual test methods.
 26    """
 27
 28def _add_good_parse_questions() -> None:
 29    """ Add test cases for parsing valid documents. """
 30
 31    paths = sorted(glob.glob(os.path.join(GOOD_DOCUMENTS_DIR, "**", "*.json"), recursive = True))
 32    for path in paths:
 33        test_cases = edq.util.json.load_path(path)
 34        base_dir = os.path.dirname(path)
 35
 36        for test_case in test_cases:
 37            name = test_case['name']
 38            text = test_case['text']
 39
 40            context = quizcomp.parser.common.RenderContext(**test_case.get('context', {}))
 41            context.base_dir = base_dir
 42
 43            for (raw_doc_format, expected) in test_case['formats'].items():
 44                doc_format = quizcomp.model.constants.Format(raw_doc_format)
 45                test_name = _make_name('good_parse', path, name, doc_format)
 46                options = test_case.get('options', {}).get(doc_format.value, {})
 47                setattr(TestParser, test_name, _get_good_parse_test(text, doc_format, expected, options, context))
 48
 49def _get_good_parse_test(
 50        text: str,
 51        doc_format: quizcomp.model.constants.Format,
 52        base_expected: typing.Union[str, typing.List[typing.Dict[str, typing.Any]], typing.Dict[str, typing.Any]],
 53        options: typing.Dict[str, typing.Any],
 54        context: quizcomp.parser.common.RenderContext,
 55        ) -> typing.Callable:
 56    """ Get a test method for a valid document. """
 57
 58    def __method(self: TestParser) -> None:
 59        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 60        result = document.to_format(doc_format, context = context)
 61
 62        if (doc_format == quizcomp.model.constants.Format.JSON):
 63            result = edq.util.json.loads(result)
 64            expected: typing.Any = {
 65                'text': text.strip(),
 66                'ast': {
 67                    'type': 'root',
 68                },
 69            }
 70
 71            expected_children = []
 72            if (len(base_expected) > 0):
 73                if (isinstance(base_expected, list)):
 74                    expected_children += base_expected
 75                elif (isinstance(base_expected, dict)):
 76                    expected_children.append(base_expected)
 77                else:
 78                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 79
 80            if (len(expected_children) > 0):
 81                # If the first node is not the root block, then automatically insert it.
 82                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 83                    expected_children = [{
 84                        'type': 'container_block',
 85                        'children': expected_children,
 86                        'attributes': {
 87                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 88                        },
 89                    }]
 90
 91                expected['ast']['children'] = expected_children
 92
 93            self.assertJSONDictEqual(expected, result)
 94        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 95            # If the HTML does not have a root block, then add one.
 96            raw_expected = str(base_expected)
 97            if (options.get('strip', True)):
 98                raw_expected = raw_expected.strip()
 99
100            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
101                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
102
103            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
104            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
105
106            expected, result = _apply_text_options(options, expected, result)
107            self.assertEqual(expected, result)
108        else:
109            expected = str(base_expected).strip()
110            result = result.strip()
111
112            expected, result = _apply_text_options(options, expected, result)
113            self.assertEqual(expected, result)
114
115    return __method
116
117def _add_bad_parse_questions() -> None:
118    """ Add test cases for parsing invalid documents. """
119
120    paths = sorted(glob.glob(os.path.join(BAD_DOCUMENTS_DIR, "**", "*.json"), recursive = True))
121    for path in paths:
122        test_cases = edq.util.json.load_path(path)
123        base_dir = os.path.dirname(path)
124
125        for test_case in test_cases:
126            name = test_case['name']
127            text = test_case['text']
128            options = test_case.get('options', {})
129
130            context = quizcomp.parser.common.RenderContext(**test_case.get('context', {}))
131            context.base_dir = base_dir
132
133            test_name = _make_name('bad_parse', path, name)
134            setattr(TestParser, test_name, _get_bad_parse_test(text, options, context))
135
136def _get_bad_parse_test(
137        text: str,
138        options: typing.Dict[str, typing.Any],
139        context: quizcomp.parser.common.RenderContext,
140        ) -> typing.Callable:
141    """ Get a test method for an invalid document. """
142
143    def __method(self: TestParser) -> None:
144        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
145        try:
146            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
147        except Exception:
148            # Expected.
149            return
150
151        self.fail("Failed to raise an exception.")
152
153    return __method
154
155def _make_name(prefix: str, path: str, name: str, doc_format: typing.Union[quizcomp.model.constants.Format, None] = None) -> str:
156    """ Create a name for a test case. """
157
158    clean_name = quizcomp.testing.base.clean_name_part(name)
159
160    filename = os.path.splitext(os.path.basename(path))[0]
161
162    test_name = f"test_{prefix}__{filename}__{clean_name}"
163
164    if (doc_format is not None):
165        test_name += ('__' + doc_format.value)
166
167    return test_name
168
169def _apply_text_options(options: typing.Dict[str, typing.Any], a: str, b: str) -> typing.Tuple[str, str]:
170    """ Apply some custom text options. """
171
172    if (options.get("ignore-whitespace", False)):
173        a = re.sub(r'\s+', '', a)
174        b = re.sub(r'\s+', '', b)
175
176    return a, b
177
178_add_bad_parse_questions()
179_add_good_parse_questions()
THIS_DIR: str = '/home/runner/work/quiz-composer/quiz-composer/quizcomp/parser'
TESTDATA_DIR: str = '/home/runner/work/quiz-composer/quiz-composer/quizcomp/parser/testdata'
DOCUMENTS_DIR = '/home/runner/work/quiz-composer/quiz-composer/quizcomp/parser/testdata/documents'
GOOD_DOCUMENTS_DIR = '/home/runner/work/quiz-composer/quiz-composer/quizcomp/parser/testdata/documents/good'
BAD_DOCUMENTS_DIR = '/home/runner/work/quiz-composer/quiz-composer/quizcomp/parser/testdata/documents/bad'
class TestParser(quizcomp.testing.base.BaseTest):
23class TestParser(quizcomp.testing.base.BaseTest):
24    """
25    Test parsing text.
26    Good and bad situations will be loaded from files into individual test methods.
27    """

Test parsing text. Good and bad situations will be loaded from files into individual test methods.

def test_bad_parse__placeholder__empty(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__placeholder__only_space(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__placeholder__not_plain_text(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__placeholder__no_closing_tag(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__style__missing_json_brace(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__style__json_list(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_bad_parse__style__missing_json_key_quote(self: TestParser) -> None:
144    def __method(self: TestParser) -> None:
145        serial_context = edq.util.serial.SerializationContext(base_dir = context.base_dir, source_path = context.source_path)
146        try:
147            quizcomp.parser.document.ParsedDocument.parse_text(text, serial_context)
148        except Exception:
149            # Expected.
150            return
151
152        self.fail("Failed to raise an exception.")
def test_good_parse__block__empty_explicit_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__empty_explicit_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__empty_explicit_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__empty_explicit_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__empty_explicit_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block_in_text__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block_in_text__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block_in_text__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block_in_text__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__explicit_block_in_text__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_empty_blocks__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_empty_blocks__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_empty_blocks__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_empty_blocks__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_empty_blocks__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_nonempty_blocks__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_nonempty_blocks__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_nonempty_blocks__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_nonempty_blocks__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__block__nested_nonempty_blocks__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_inline_code__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_inline_code__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_inline_code__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_inline_code__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_inline_code__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__midtext_inline_code__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__midtext_inline_code__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__midtext_inline_code__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__midtext_inline_code__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__midtext_inline_code__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_escapes__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_escapes__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_escapes__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_escapes__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_escapes__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_unescapes__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_unescapes__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_unescapes__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_unescapes__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_unescapes__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_alt_verb_delim__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_alt_verb_delim__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_alt_verb_delim__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_alt_verb_delim__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__inline_code_with_alt_verb_delim__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_code_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_code_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_code_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_code_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__basic_code_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_inner_whitespace__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_inner_whitespace__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_inner_whitespace__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_inner_whitespace__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_inner_whitespace__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_info_string__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_info_string__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_info_string__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_info_string__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_block_with_info_string__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__indented_code_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__indented_code_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__indented_code_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__indented_code_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__indented_code_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_with_less_than__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_with_less_than__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_with_less_than__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_with_less_than__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__code__code_with_less_than__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__basic_comment__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__basic_comment__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__basic_comment__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__basic_comment__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__basic_comment__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__inline_comment__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__inline_comment__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__inline_comment__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__inline_comment__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__comment__inline_comment__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_inline_equation__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_inline_equation__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_inline_equation__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_inline_equation__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_inline_equation__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_without_whitespace__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_without_whitespace__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_without_whitespace__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_without_whitespace__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_without_whitespace__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_dollar_sign__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_dollar_sign__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_dollar_sign__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_dollar_sign__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_dollar_sign__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_equation_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_equation_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_equation_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_equation_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__basic_equation_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_unescaped_escape_characters__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_unescaped_escape_characters__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_unescaped_escape_characters__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_unescaped_escape_characters__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_unescaped_escape_characters__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_terminal_newlines__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_terminal_newlines__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_terminal_newlines__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_terminal_newlines__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_terminal_newlines__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_inner_newlines__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_inner_newlines__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_inner_newlines__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_inner_newlines__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__equation_block_with_inner_newlines__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__allow_text_math__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__allow_text_math__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__allow_text_math__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__allow_text_math__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__allow_text_math__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_angle_bracket__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_angle_bracket__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_angle_bracket__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_angle_bracket__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__equation__inline_equation_with_angle_bracket__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_slash__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_slash__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_slash__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_slash__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_slash__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backslash__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backslash__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backslash__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backslash__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backslash__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_asterisk__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_asterisk__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_asterisk__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_asterisk__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_asterisk__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_dollar_sign__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_dollar_sign__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_dollar_sign__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_dollar_sign__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_dollar_sign__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_open_bracket__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_open_bracket__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_open_bracket__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_open_bracket__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_open_bracket__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backtick__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backtick__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backtick__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backtick__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__escape__escaped_backtick__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_remote_image__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_remote_image__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_remote_image__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_remote_image__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_remote_image__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_local_image__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_local_image__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_local_image__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_local_image__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__basic_local_image__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__data_url__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__data_url__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__data_url__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__data_url__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__image__data_url__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_unordered_list__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_unordered_list__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_unordered_list__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_unordered_list__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_unordered_list__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_ordered_list__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_ordered_list__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_ordered_list__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_ordered_list__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__list__basic_ordered_list__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break_with_text__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break_with_text__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break_with_text__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break_with_text__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__thematic_break_with_text__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__basic_blockquote__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__basic_blockquote__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__basic_blockquote__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__basic_blockquote__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__misc__basic_blockquote__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__canvas(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_block__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__canvas(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__html_inline__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__canvas(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__underscore__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__canvas(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__space__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__canvas(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__placeholder__one_character__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_root_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_root_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_root_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_root_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_root_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__optional_braces__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__optional_braces__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__optional_braces__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__optional_braces__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__optional_braces__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_explicit_block_with_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_explicit_block_with_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_explicit_block_with_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_explicit_block_with_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__empty_explicit_block_with_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__explicit_block_with_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__explicit_block_with_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__explicit_block_with_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__explicit_block_with_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__explicit_block_with_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__root_style_alongside_text__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__root_style_alongside_text__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__root_style_alongside_text__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__root_style_alongside_text__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__root_style_alongside_text__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_override_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_override_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_override_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_override_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_override_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_clear_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_clear_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_clear_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_clear_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__nest_clear_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style_override__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style_override__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style_override__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style_override__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style__context_style_override__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_center__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_center__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_center__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_center__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_center__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_left__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_left__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_left__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_left__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_left__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_right__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_right__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_right__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_right__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_content_align_right__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_center__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_center__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_center__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_center__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_center__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_left__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_left__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_left__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_left__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_alignment__basic_text_align_left__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__basic_image_width__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__basic_image_width__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__basic_image_width__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__basic_image_width__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__basic_image_width__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_width__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_width__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_width__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_width__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_width__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_override_width__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_override_width__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_override_width__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_override_width__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_override_width__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_clear_width__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_clear_width__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_clear_width__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_clear_width__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_image__nested_image_clear_width__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_head_rule__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_head_rule__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_head_rule__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_head_rule__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_head_rule__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_bold_headers__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_bold_headers__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_bold_headers__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_bold_headers__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__no_bold_headers__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells_multirow__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells_multirow__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells_multirow__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells_multirow__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_cells_multirow__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_table__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_table__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_table__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_table__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__border_table__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__full_border__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__full_border__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__full_border__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__full_border__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__full_border__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_height__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_height__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_height__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_height__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_height__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_width__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_width__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_width__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_width__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__base_cell_width__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__table_with_content_and_text_alignment__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__table_with_content_and_text_alignment__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__table_with_content_and_text_alignment__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__table_with_content_and_text_alignment__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__style_table__table_with_content_and_text_alignment__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__basic_table__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__basic_table__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__basic_table__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__basic_table__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__basic_table__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_gfm_alignment__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_gfm_alignment__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_gfm_alignment__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_gfm_alignment__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_gfm_alignment__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_differnet_text_types__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_differnet_text_types__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_differnet_text_types__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_differnet_text_types__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__table__table_with_differnet_text_types__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_word__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_word__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_word__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_word__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_word__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_spaces__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_spaces__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_spaces__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_spaces__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_spaces__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_newlines__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_newlines__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_newlines__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_newlines__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_newlines__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_hardbreak__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_hardbreak__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_hardbreak__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_hardbreak__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_implicit_hardbreak__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_explicit_linebreak__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_explicit_linebreak__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_explicit_linebreak__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_explicit_linebreak__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__text_with_explicit_linebreak__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_italics__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_italics__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_italics__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_italics__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_italics__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__nonitalics_stars__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__nonitalics_stars__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__nonitalics_stars__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__nonitalics_stars__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__nonitalics_stars__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_bold__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_bold__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_bold__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_bold__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__basic_bold__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_and_italics__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_and_italics__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_and_italics__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_and_italics__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_and_italics__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_spaces__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_spaces__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_spaces__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_spaces__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_spaces__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__tex_escape_carrot__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__tex_escape_carrot__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__tex_escape_carrot__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__tex_escape_carrot__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__tex_escape_carrot__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape_carrot__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape_carrot__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape_carrot__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape_carrot__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__bold_with_tex_escape_carrot__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_heading__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_heading__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_heading__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_heading__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__single_heading__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__multiple_headings__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__multiple_headings__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__multiple_headings__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__multiple_headings__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__multiple_headings__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__setext_heading__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__setext_heading__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__setext_heading__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__setext_heading__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__setext_heading__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__allow_text_all_characters__md(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__allow_text_all_characters__html(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__allow_text_all_characters__tex(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__allow_text_all_characters__text(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)
def test_good_parse__text__allow_text_all_characters__json(self: TestParser) -> None:
 59    def __method(self: TestParser) -> None:
 60        document = quizcomp.parser.document.ParsedDocument.parse_text(text)
 61        result = document.to_format(doc_format, context = context)
 62
 63        if (doc_format == quizcomp.model.constants.Format.JSON):
 64            result = edq.util.json.loads(result)
 65            expected: typing.Any = {
 66                'text': text.strip(),
 67                'ast': {
 68                    'type': 'root',
 69                },
 70            }
 71
 72            expected_children = []
 73            if (len(base_expected) > 0):
 74                if (isinstance(base_expected, list)):
 75                    expected_children += base_expected
 76                elif (isinstance(base_expected, dict)):
 77                    expected_children.append(base_expected)
 78                else:
 79                    raise ValueError(f"Unkown type for expected children: '{type(base_expected)}'.")
 80
 81            if (len(expected_children) > 0):
 82                # If the first node is not the root block, then automatically insert it.
 83                if (not expected_children[0].get('attributes', {}).get(quizcomp.parser.common.TOKEN_META_KEY_ROOT, False)):
 84                    expected_children = [{
 85                        'type': 'container_block',
 86                        'children': expected_children,
 87                        'attributes': {
 88                            quizcomp.parser.common.TOKEN_META_KEY_ROOT: True,
 89                        },
 90                    }]
 91
 92                expected['ast']['children'] = expected_children
 93
 94            self.assertJSONDictEqual(expected, result)
 95        elif (doc_format in {quizcomp.model.constants.Format.CANVAS, quizcomp.model.constants.Format.HTML}):
 96            # If the HTML does not have a root block, then add one.
 97            raw_expected = str(base_expected)
 98            if (options.get('strip', True)):
 99                raw_expected = raw_expected.strip()
100
101            if ((raw_expected != '') and ('qg-root-block' not in raw_expected)):
102                raw_expected = '<div class="qg-root-block qg-block">' + raw_expected + '</div>'
103
104            expected = quizcomp.util.html.clean(raw_expected, pretty = options.get('pretty', True))
105            result = quizcomp.util.html.clean(result, pretty = options.get('pretty', True))
106
107            expected, result = _apply_text_options(options, expected, result)
108            self.assertEqual(expected, result)
109        else:
110            expected = str(base_expected).strip()
111            result = result.strip()
112
113            expected, result = _apply_text_options(options, expected, result)
114            self.assertEqual(expected, result)