Skip to content

Test failiure on Python 3.8 #343

Closed
@Aniket-Pradhan

Description

@Aniket-Pradhan

Hello there!

Thanks for working on and providing python-odml. 😄

We were working on packaging this tool for Fedora, and it seems that one of the tests fails on Python 3.8. No worries, it seems to be an issue of PyYaml (ref). As per the team working on PyYaml, this should be resolved in the next stable release.

On the other hand, for now, we can add Loader=yaml.Loader in odmlparser.py#136 to fix the issue. I have checked, and it does not break any tests.

I will send in a quick PR to fix the issue. :D

The error log is here;

self = <test.test_dtypes_integration.TestTypesIntegration testMethod=test_time>

    def test_time(self):
        time_string = '12:34:56'
        time = dt.time(12, 34, 56)
        val_in = time_string
        vals_in = [None, "", time_string, time]
        parent_sec = self.doc.sections[0]
        _ = odml.Property(name="time test single", dtype="time",
                          value=val_in, parent=parent_sec)
        _ = odml.Property(name="time test", dtype="time",
                          value=vals_in, parent=parent_sec)
    
        # Test correct json save and load.
        odml.save(self.doc, self.json_file, "JSON")
        jdoc = odml.load(self.json_file, "JSON")
    
        self.assertEqual(jdoc.sections[0].properties[0].dtype, odml.dtypes.DType.time)
        self.assertIsInstance(jdoc.sections[0].properties[0].values[0], dt.time)
        self.assertEqual(jdoc.sections[0].properties[1].dtype, odml.dtypes.DType.time)
        for val in jdoc.sections[0].properties[1].value:
            self.assertIsInstance(val, dt.time)
        self.assertEqual(jdoc.sections[0].properties[1].values[2], time)
        self.assertEqual(jdoc.sections[0].properties[1].values[3], time)
        self.assertEqual(self.doc, jdoc)
    
        # Test correct xml save and load.
        odml.save(self.doc, self.xml_file)
        xdoc = odml.load(self.xml_file)
    
        self.assertEqual(xdoc.sections[0].properties[0].dtype, odml.dtypes.DType.time)
        self.assertIsInstance(xdoc.sections[0].properties[0].values[0], dt.time)
        self.assertEqual(xdoc.sections[0].properties[1].dtype, odml.dtypes.DType.time)
        for val in xdoc.sections[0].properties[1].value:
            self.assertIsInstance(val, dt.time)
        self.assertEqual(xdoc.sections[0].properties[1].values[2], time)
        self.assertEqual(xdoc.sections[0].properties[1].values[2], time)
        self.assertEqual(self.doc, xdoc)
    
        # Test correct yaml save and load.
        odml.save(self.doc, self.yaml_file, "YAML")
>       ydoc = odml.load(self.yaml_file, "YAML")

test/test_dtypes_integration.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
odml/fileio.py:21: in load
    return reader.from_file(filename)
odml/tools/odmlparser.py:136: in from_file
    self.parsed_doc = yaml.load(yaml_data)
.venv/lib64/python3.8/site-packages/yaml/__init__.py:114: in load
    return loader.get_single_data()
.venv/lib64/python3.8/site-packages/yaml/constructor.py:43: in get_single_data
    return self.construct_document(node)
.venv/lib64/python3.8/site-packages/yaml/constructor.py:52: in construct_document
    for dummy in generator:
.venv/lib64/python3.8/site-packages/yaml/constructor.py:399: in construct_yaml_seq
    data.extend(self.construct_sequence(node))
.venv/lib64/python3.8/site-packages/yaml/constructor.py:121: in construct_sequence
    return [self.construct_object(child, deep=deep)
.venv/lib64/python3.8/site-packages/yaml/constructor.py:121: in <listcomp>
    return [self.construct_object(child, deep=deep)
.venv/lib64/python3.8/site-packages/yaml/constructor.py:92: in construct_object
    data = constructor(self, node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <yaml.loader.FullLoader object at 0x7f27eff0a3a0>
node = SequenceNode(tag='tag:yaml.org,2002:python/object/apply:datetime.time', value=[ScalarNode(tag='tag:yaml.org,2002:binary', value='DCI4AAAA\n')])

    def construct_undefined(self, node):
>       raise ConstructorError(None, None,
                "could not determine a constructor for the tag %r" % node.tag,
                node.start_mark)
E       yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/apply:datetime.time'
E         in "/tmp/tmp_jhz9b1i.odml/test.yaml", line 11, column 9

.venv/lib64/python3.8/site-packages/yaml/constructor.py:418: ConstructorError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions