Skip to content

Commit

Permalink
Fix group encoding errors
Browse files Browse the repository at this point in the history
  - TestEncoding.test_encode_unordered_content_2(): last test now
    raises the correct message (fixed index calculation for missing
    content tail)
  • Loading branch information
brunato committed Dec 23, 2019
1 parent 2381c4f commit a17f385
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions xmlschema/tests/validation/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,10 @@ def test_encode_unordered_content_2(self):
expected=u'<A>\nhello<B1>abc</B1>\n<B2>10</B2>\n<B3>true</B3>\n</A>',
indent=0, cdata_prefix='#'
)
from xmlschema.converters import XMLSchemaConverter
# FIXME: UnorderedConverter do not work, an XMLSchemaValidationError is expected!!
self.check_encode(
xsd_component=schema.elements['A'], converter=XMLSchemaConverter, unordered=True,
xsd_component=schema.elements['A'],
data=ordered_dict_class([('B1', 'abc'), ('B2', 10), ('#1', 'hello')]),
expected=u'<A>\nhello<B1>abc</B1>\n<B2>10</B2>\n</A>', indent=0, cdata_prefix='#'
expected=XMLSchemaValidationError, indent=0, cdata_prefix='#'
)

def test_strict_trailing_content(self):
Expand Down
2 changes: 1 addition & 1 deletion xmlschema/validators/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def iter_encode(self, element_data, validation='lax', **kwargs):

if model.element is not None:
for particle, occurs, expected in model.stop():
errors.append((index - cdata_index, particle, occurs, expected))
errors.append((index - cdata_index + 1, particle, occurs, expected))

if children:
if children[-1].tail is None:
Expand Down

0 comments on commit a17f385

Please sign in to comment.