Skip to content

Commit

Permalink
Merge pull request #147 from khaeru/issue/146
Browse files Browse the repository at this point in the history
Use supplied DSD for structure-specific messages
  • Loading branch information
khaeru authored Nov 15, 2023
2 parents c28f50a + e5c358a commit c56574a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Next release
============

- Python 3.12 (released 2023-10-02) is fully supported (:pull:`145`).
- Bugfix: :py:`dsd=...` argument supplied to the SDMX-ML reader ignored in v2.11.0 and later, causing a warning (:pull:`147`; thanks :gh-user:`miccoli` for :issue:`146`).

v2.12.0 (2023-10-11)
====================
Expand Down
2 changes: 1 addition & 1 deletion sdmx/reader/xml/v21.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def _message(reader: Reader, elem):
# With 'dsd' argument, the message should be structure-specific
if (
"StructureSpecific" in elem.tag
and reader.get_single(common.BaseDataStructureDefinition) is None
and reader.get_single(common.BaseDataStructureDefinition, subclass=True) is None
):
log.warning(f"xml.Reader got no dsd=… argument for {QName(elem).localname}")
ss_without_dsd = True
Expand Down
9 changes: 7 additions & 2 deletions sdmx/tests/test_dataset_ss.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from collections.abc import Mapping

import pandas as pd
Expand Down Expand Up @@ -26,9 +27,13 @@ def msg(self, path, dsd):
yield sdmx.read_sdmx(path / self.filename, dsd=dsd)

# Tests for every class
def test_msg(self, path, dsd):
def test_msg(self, caplog, path, dsd):
# The message can be parsed
sdmx.read_sdmx(path / self.filename, dsd=dsd)
with caplog.at_level(logging.WARNING):
sdmx.read_sdmx(path / self.filename, dsd=dsd)

# No warnings are emitted per missing dsd= argument (khaeru/sdmx#146)
assert [] == caplog.messages

def test_structured_by(self, dsd, msg):
# The DSD was used to parse the message
Expand Down

0 comments on commit c56574a

Please sign in to comment.