Skip to content

Commit b053529

Browse files
committed
PYTHON-4834 Add __repr__ to IndexModel
- Don't move assertRepr
1 parent aec60d2 commit b053529

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

test/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import pymongo
7070
import pymongo.errors
7171
from bson.son import SON
72-
from pymongo import IndexModel # noqa
7372
from pymongo.common import partition_node
7473
from pymongo.hello import HelloCompat
7574
from pymongo.server_api import ServerApi
@@ -867,11 +866,6 @@ def assertEqualCommand(self, expected, actual, msg=None):
867866
def assertEqualReply(self, expected, actual, msg=None):
868867
self.assertEqual(sanitize_reply(expected), sanitize_reply(actual), msg)
869868

870-
def assertRepr(self, obj):
871-
new_obj = eval(repr(obj))
872-
self.assertEqual(type(new_obj), type(obj))
873-
self.assertEqual(repr(new_obj), repr(obj))
874-
875869
@contextmanager
876870
def fail_point(self, command_args):
877871
cmd_on = SON([("configureFailPoint", "failCommand")])

test/test_connection_monitoring.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ def test_5_check_out_fails_auth_error(self):
421421
#
422422
# Extra non-spec tests
423423
#
424+
def assertRepr(self, obj):
425+
new_obj = eval(repr(obj))
426+
self.assertEqual(type(new_obj), type(obj))
427+
self.assertEqual(repr(new_obj), repr(obj))
428+
424429
def test_events_repr(self):
425430
host = ("localhost", 27017)
426431
self.assertRepr(ConnectionCheckedInEvent(host, 1))

test/test_operations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
class TestOperations(UnitTest):
2424
"""Test the operations module."""
25+
def assertRepr(self, obj):
26+
new_obj = eval(repr(obj))
27+
self.assertEqual(type(new_obj), type(obj))
28+
self.assertEqual(repr(new_obj), repr(obj))
2529

2630
def test_index_model_repr(self):
2731
# Based on examples in test_collection.py

0 commit comments

Comments
 (0)