Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test_toml_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,20 @@ def test_replace_preserve_sep() -> None:
)


def test_replace_table_with_itself_preserves_display_name() -> None:
content = """\
[keys.a]
[keys .'a'.'c']
'd'\t= 'e'
"""
doc = parse(content)

for mode in doc["keys"]:
doc["keys"][mode] = doc["keys"][mode]

assert doc.as_string() == content


def test_replace_with_table_of_nested() -> None:
example = """\
[a]
Expand Down
2 changes: 1 addition & 1 deletion tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ def _replace_at(
value.trivia.trail = v.trivia.trail
self._body[idx] = (new_key, value)

if hasattr(value, "invalidate_display_name"):
if value is not v and hasattr(value, "invalidate_display_name"):
value.invalidate_display_name()

if isinstance(value, Table):
Expand Down
Loading