FAILED asdf/_tests/test_yaml.py::test_implicit_conversion_warning
Closed this issue · 3 comments
Hi,
While refreshing the package for Guix one unit test has failed.
Description of the problem
=================================== FAILURES ===================================
_______________________ test_implicit_conversion_warning _______________________
[gw4] linux -- Python 3.10.7 /gnu/store/jh59fh48mcffyz5wmsjj0p96xkkflbz0-python-wrapper-3.10.7/bin/python
def test_implicit_conversion_warning():
nt = namedtuple("TestTupleWarning", ("one", "two", "three"))
tree = {"val": nt(1, 2, np.ones(3))}
> with (
pytest.warns(AsdfWarning, match=r"Failed to serialize instance"),
pytest.warns(AsdfDeprecationWarning, match=r"implicit conversion is deprecated"),
asdf.AsdfFile(tree),
):
E Failed: DID NOT WARN. No warnings of type (<class 'asdf.exceptions.AsdfWarning'>,) were emitted. The list of emitted warnings is: [].
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/test_yaml.py:203: Failed
=========================== short test summary info ============================
SKIPPED [3] ../../../gnu/store/glrxjwic379h2gmyxc2sfchvnw5g1aai-python-pytest-7.1.3/lib/python3.10/site-packages/_pytest/doctest.py:452: all tests skipped by +SKIP option
SKIPPED [9] ../../../gnu/store/7q3d3n6wjhvp4wfbm742yf90wi7yipc4-python-pytest-remotedata-0.4.1/lib/python3.10/site-packages/pytest_remotedata/plugin.py:81: need --remote-data option to run
SKIPPED [1] asdf/_tests/test_reference_files.py:55: got empty parameter set ['reference_file'], function test_reference_file at /tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/test_reference_files.py:54
XFAIL asdf/_tests/test_yaml.py::test_python_tuple_key
pyyaml has a bug and does not support tuple keys
XFAIL asdf/_tests/_regtests/test_1539.py::test_invalid_seek_and_read_from_closed_memoryio
Fix will require more major changes to generic_io
FAILED asdf/_tests/test_yaml.py::test_implicit_conversion_warning - Failed: D...
============ 1 failed, 1834 passed, 13 skipped, 2 xfailed in 12.29s ============
Example of the problem
/bin/pytest -vv -n auto -p "no:legacypath"
System information
- Python :: 3.10.7
- Guix :: local checkout
- python-asdf@3.3.0
- python-fsspec@2023.5.0
- python-packaging@21.3
- python-psutil@5.9.2
- python-pytest@7.1.3
- python-pytest-doctestplus@1.2.0
- python-pytest-remotedata@0.4.1
- python-pytest-xdist@2.5.0
- python-setuptools-scm@7.1.0
- python-asdf-standard@1.1.1
- python-asdf-transform-schemas@0.5.0
- python-attrs@21.2.0
- python-importlib-metadata@5.2.0
- python-jmespath@1.0.1
- python-lz4@4.3.2
- python-numpy@1.23.2
- python-pyyaml@6.0
- python-semantic-version@2.8.5
Thanks for opening an issue.
I believe this is due to using pytest<8 (pytest 8 changed how warnings are captured). I was able to replicate this by installing pytest 7.3.
If possible would you try with a more recent version of pytest (version 8 or greater). I'll add a lower pin for pytest in the requirements for this package but it's unlikely we'll make a release with this pin anytime soon.
Hi @braingram
Thanks for suggestion. I've refreshed pytest to 8.2.2 and formally all tests passed and I've got this trace:
================================== XFAILURES ===================================
_______________ test_invalid_seek_and_read_from_closed_memoryio ________________
@pytest.mark.xfail(reason="Fix will require more major changes to generic_io")
def test_invalid_seek_and_read_from_closed_memoryio():
"""
Seek and read from closed MemoryIO
https://github.com/asdf-format/asdf/issues/1539
"""
b = io.BytesIO()
b.write(b"\0" * 10)
b.seek(0)
f = asdf.generic_io.get_file(b)
f.close()
> with pytest.raises(IOError, match="I/O operation on closed file."):
E Failed: DID NOT RAISE <class 'OSError'>
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/_regtests/test_1539.py:20: Failed
____________________________ test_python_tuple_key _____________________________
@pytest.mark.xfail(reason="pyyaml has a bug and does not support tuple keys")
def test_python_tuple_key():
"""
This tests whether tuple keys are round-tripped properly.
As of this writing, this does not work in pyyaml but does work in
ruamel.yaml. If/when we decide to switch to ruamel.yaml, this test should
pass.
"""
input_tree = {(42, 1): "foo"}
> _, tree = _roundtrip(input_tree)
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/test_yaml.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/test_yaml.py:47: in _roundtrip
with asdf.open(buff, **open_kwargs) as af:
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_asdf.py:1740: in open_asdf
return AsdfFile._open_impl(
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_asdf.py:1015: in _open_impl
return cls._open_asdf(
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_asdf.py:951: in _open_asdf
tree = yamlutil.load_tree(reader)
/tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/yamlutil.py:361: in load_tree
return yaml.load(stream, Loader=AsdfLoader) # noqa: S506
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/__init__.py:81: in load
return loader.get_single_data()
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/constructor.py:51: in get_single_data
return self.construct_document(node)
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/constructor.py:60: in construct_document
for dummy in generator:
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/constructor.py:413: in construct_yaml_map
value = self.construct_mapping(node)
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/constructor.py:218: in construct_mapping
return super().construct_mapping(node, deep=deep)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <asdf.yamlutil.AsdfLoader object at 0x13b8540>
node = MappingNode(tag='tag:yaml.org,2002:map', value=[(SequenceNode(tag='tag:yaml.org,2002:seq', value=[ScalarNode(tag='tag:...ue='42'), ScalarNode(tag='tag:yaml.org,2002:int', value='1')]), ScalarNode(tag='tag:yaml.org,2002:str', value='foo'))])
deep = False
def construct_mapping(self, node, deep=False):
if not isinstance(node, MappingNode):
raise ConstructorError(None, None,
"expected a mapping node, but found %s" % node.id,
node.start_mark)
mapping = {}
for key_node, value_node in node.value:
key = self.construct_object(key_node, deep=deep)
if not isinstance(key, collections.abc.Hashable):
> raise ConstructorError("while constructing a mapping", node.start_mark,
"found unhashable key", key_node.start_mark)
E yaml.constructor.ConstructorError: while constructing a mapping
E in "<file>", line 14, column 3
E found unhashable key
E in "<file>", line 14, column 5
/gnu/store/5waxhk0gwydl7gq6jlzhy56pry8pvjf2-python-pyyaml-6.0/lib/python3.10/site-packages/yaml/constructor.py:141: ConstructorError
=========================== short test summary info ============================
SKIPPED [9] ../../../gnu/store/7q3d3n6wjhvp4wfbm742yf90wi7yipc4-python-pytest-remotedata-0.4.1/lib/python3.10/site-packages/pytest_remotedata/plugin.py:81: need --remote-data option to run
SKIPPED [1] asdf/_tests/test_reference_files.py:55: got empty parameter set ['reference_file'], function test_reference_file at /tmp/guix-build-python-asdf-3.3.0.drv-0/asdf-3.3.0/asdf/_tests/test_reference_files.py:54
SKIPPED [3] ../../../gnu/store/cgc5v15whfq60q68cq3y0jbgqid5nyfz-python-pytest-8.2.2/lib/python3.10/site-packages/_pytest/doctest.py:461: all tests skipped by +SKIP option
XFAIL asdf/_tests/_regtests/test_1539.py::test_invalid_seek_and_read_from_closed_memoryio - Fix will require more major changes to generic_io
XFAIL asdf/_tests/test_yaml.py::test_python_tuple_key - pyyaml has a bug and does not support tuple keys
================= 1835 passed, 13 skipped, 2 xfailed in 56.47s =================
I may assume that is expected behavior.
Oleg
Thanks! Yes that looks correct, all xfails and skips but no failures. I'll close this issue and the linked PR should address the issue for future releases.