Skip to content

Dumping a subelement of a parsed toml fails starting on 4rd level of nesting #411

@ewjoachim

Description

@ewjoachim

Hi :) Nice lib! <3

The shortest way to expose the issue:

from tomlkit import dumps, parse


def test_reproducer():
    a = parse("a.b.c.d='e'")["a"]
    assert a == {"b": {"c": {"d": "e"}}}  # ok
    assert dumps(a) == "b.c.d='e'"
$ pytest
____________ test_reproducer ____________

    def test_reproducer():
        a = parse("a.b.c.d='e'")["a"]
        assert a == {"b": {"c": {"d": "e"}}}  # ok
>       assert dumps(a) == "b.c.d='e'"
E       assert "c.d='e'" == "b.c.d='e'"
E
E         - b.c.d='e'
E         ? --
E         + c.d='e'

script.py:9: AssertionError
======== short test summary info ========
FAILED script.py::test_reproducer - assert "c.d='e'" == "b.c.d='e'"

  - b.c.d='e'
  ? --
  + c.d='e'
=========== 1 failed in 0.03s ===========

This doesn't happen if the dict is less nested than 4 levels, but it happens for higher levels of nesting too.

Metadata

Metadata

Assignees

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