Skip to content

Commit

Permalink
Fix unit tests for lxml
Browse files Browse the repository at this point in the history
  • Loading branch information
medley56 committed Sep 1, 2024
1 parent 6a45a6b commit 72278fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions space_packet_parser/xtcedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,7 @@ def __init__(self, xtce_document: TextIO, ns: Optional[dict] = None):
"""
self._sequence_container_cache = {} # Lookup for parsed sequence container objects
self._parameter_cache = {} # Lookup for parsed parameter objects
self._parameter_type_cache = {} # Lookup for parsed parameter type objects
self.tree = ElementTree.parse(xtce_document)
self.ns = ns or self.tree.getroot().nsmap
self.type_tag_to_object = {k.format(**self.ns): v for k, v in
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_xtcedef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for space_packet_parser.xtcedef"""
# Standard
from io import StringIO
import io
# Installed
import pytest
import lxml.etree as ElementTree
Expand Down Expand Up @@ -39,9 +39,9 @@ def test_invalid_parameter_type_error(test_data_dir):
</xtce:TelemetryMetaData>
</xtce:SpaceSystem>
"""
x = StringIO(test_xtce_document)
x = io.TextIOWrapper(io.BytesIO(test_xtce_document.encode("utf-8")))
with pytest.raises(xtcedef.InvalidParameterTypeError):
xtcedef.XtcePacketDefinition(x, ns=TEST_NAMESPACE)
xtcedef.XtcePacketDefinition(x)


def test_unsupported_parameter_type_error(test_data_dir):
Expand Down Expand Up @@ -80,9 +80,9 @@ def test_unsupported_parameter_type_error(test_data_dir):
</xtce:TelemetryMetaData>
</xtce:SpaceSystem>
"""
x = StringIO(test_xtce_document)
x = io.TextIOWrapper(io.BytesIO(test_xtce_document.encode("utf-8")))
with pytest.raises(NotImplementedError):
xtcedef.XtcePacketDefinition(x, ns=TEST_NAMESPACE)
xtcedef.XtcePacketDefinition(x)


def test_attr_comparable():
Expand Down

0 comments on commit 72278fb

Please sign in to comment.