Skip to content

Commit 8cc8b50

Browse files
Add few more tests.
1 parent da57970 commit 8cc8b50

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lib/test/test_userdict.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,21 @@ def test_init(self):
168168
def test_data(self):
169169
u = UserDict()
170170
self.assertEqual(u.data, {})
171+
self.assertIs(type(u.data), dict)
171172
d = {'a': 1, 'b': 2}
172173
u = UserDict(d)
173174
self.assertEqual(u.data, d)
174175
self.assertIsNot(u.data, d)
176+
self.assertIs(type(u.data), dict)
177+
u = UserDict(u)
178+
self.assertEqual(u.data, d)
179+
self.assertIs(type(u.data), dict)
175180
u = UserDict([('a', 1), ('b', 2)])
176181
self.assertEqual(u.data, d)
182+
self.assertIs(type(u.data), dict)
177183
u = UserDict(a=1, b=2)
178184
self.assertEqual(u.data, d)
185+
self.assertIs(type(u.data), dict)
179186

180187
def test_update(self):
181188
for kw in 'self', 'dict', 'other', 'iterable':

Lib/test/test_userlist.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ class UserListTest(list_tests.CommonTest):
1919
def test_data(self):
2020
u = UserList()
2121
self.assertEqual(u.data, [])
22+
self.assertIs(type(u.data), list)
2223
a = [1, 2]
2324
u = UserList(a)
2425
self.assertEqual(u.data, a)
2526
self.assertIsNot(u.data, a)
27+
self.assertIs(type(u.data), list)
28+
u = UserList(u)
29+
self.assertEqual(u.data, a)
30+
self.assertIs(type(u.data), list)
2631
u = UserList("spam")
2732
self.assertEqual(u.data, list("spam"))
33+
self.assertIs(type(u.data), list)
2834

2935
def test_getslice(self):
3036
super().test_getslice()

Lib/test/test_userstring.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ def checkcall(self, object, methodname, *args):
4949
# we don't fix the arguments, because UserString can't cope with it
5050
getattr(object, methodname)(*args)
5151

52+
def test_data(self):
53+
u = UserString("spam")
54+
self.assertEqual(u.data, "spam")
55+
self.assertIs(type(u.data), str)
56+
u = UserString(u)
57+
self.assertEqual(u.data, "spam")
58+
self.assertIs(type(u.data), str)
59+
u = UserString(42)
60+
self.assertEqual(u.data, "42")
61+
self.assertIs(type(u.data), str)
62+
5263
def test_mixed_add(self):
5364
u = UserString("spam") + "eggs"
5465
self.assertEqual(u, "spameggs")

0 commit comments

Comments
 (0)