Skip to content

Commit d592a7e

Browse files
committed
Unroll subtests.
1 parent 03f186f commit d592a7e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/model_fields_/test_objectidfield.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ def test_get_internal_type(self):
1717
f = ObjectIdField()
1818
self.assertEqual(f.get_internal_type(), "ObjectIdField")
1919

20-
def test_to_python(self):
21-
f = ObjectIdField()
22-
expected = ObjectId("1" * 24)
23-
for value in ["1" * 24, ObjectId("1" * 24)]:
24-
with self.subTest(value=value):
25-
self.assertEqual(f.to_python(value), expected)
26-
with self.subTest(value=None):
27-
self.assertIsNone(f.to_python(None))
20+
def test_to_python_string(self):
21+
base_string = "1" * 24
22+
expected = ObjectId(base_string)
23+
self.assertEqual(ObjectIdField().to_python(base_string), expected)
24+
25+
def test_to_python_objectid(self):
26+
base_string = "1" * 24
27+
expected = ObjectId(base_string)
28+
self.assertEqual(ObjectIdField().to_python(expected), expected)
29+
30+
def test_to_python_null_value(self):
31+
self.assertIsNone(ObjectIdField().to_python(None))
2832

2933
def test_to_python_invalid_value(self):
3034
for invalid_value in ["None", {}, []]:

0 commit comments

Comments
 (0)