Skip to content

Commit ca90e39

Browse files
committed
PYTHON-4834 Add __repr__ to IndexModel
- Add test
1 parent f21ec55 commit ca90e39

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pymongo/operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def document(self) -> dict[str, Any]:
774774
return self.__document
775775

776776
def __repr__(self) -> str:
777-
return f"{self.__class__.__name__}({self.__document})"
777+
return f"{self.__class__.__name__}({self.document})"
778778

779779

780780
class SearchIndexModel:

test/test_collection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,10 @@ def afind(*args, **kwargs):
22532253
for helper, args in helpers:
22542254
helper(*args, let={}) # type: ignore
22552255

2256+
def test_repr(self):
2257+
im = IndexModel("hello")
2258+
self.assertEqual(im.__repr__(), f"{im.__class__.__name__}({im.document})")
2259+
22562260

22572261
if __name__ == "__main__":
22582262
unittest.main()

0 commit comments

Comments
 (0)