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
11 changes: 11 additions & 0 deletions tests/test_toml_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,17 @@ def test_repr() -> None:
assert repr(doc["namespace"]) == "{'key1': 'value1', 'key2': 'value2'}"


def test_repr_out_of_order_table_proxy() -> None:
doc = parse("""\
a.b.c = "d"
a.b.e = "f"
""")
expected = "{'b': {'c': 'd', 'e': 'f'}}"

assert repr(doc["a"]) == expected
assert str(doc["a"]) == expected


def test_deepcopy() -> None:
content = """
[tool]
Expand Down
6 changes: 6 additions & 0 deletions tomlkit/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,12 @@ def unwrap(self) -> dict[str, Any]:
def value(self) -> dict[str, Any]:
return self._internal_container.value

def __str__(self) -> str:
return str(self.value)

def __repr__(self) -> str:
return repr(self.value)

def __contains__(self, key: object) -> bool:
# Native membership test. The inherited ``MutableMapping.__contains__``
# resolves the value via ``__getitem__`` (and builds a ``NonExistentKey``
Expand Down
Loading