ยปCore Development>Code coverage>Lib/test/test_userstring.py

Python code coverage for Lib/test/test_userstring.py

#countcontent
1n/a# UserString is a wrapper around the native builtin string type.
2n/a# UserString instances should behave similar to builtin string objects.
3n/a
4n/aimport unittest
5n/afrom test import string_tests
6n/a
7n/afrom collections import UserString
8n/a
9n/aclass UserStringTest(
10n/a string_tests.CommonTest,
11n/a string_tests.MixinStrUnicodeUserStringTest,
12n/a unittest.TestCase
13n/a ):
14n/a
15n/a type2test = UserString
16n/a
17n/a # Overwrite the three testing methods, because UserString
18n/a # can't cope with arguments propagated to UserString
19n/a # (and we don't test with subclasses)
20n/a def checkequal(self, result, object, methodname, *args, **kwargs):
21n/a result = self.fixtype(result)
22n/a object = self.fixtype(object)
23n/a # we don't fix the arguments, because UserString can't cope with it
24n/a realresult = getattr(object, methodname)(*args, **kwargs)
25n/a self.assertEqual(
26n/a result,
27n/a realresult
28n/a )
29n/a
30n/a def checkraises(self, exc, obj, methodname, *args):
31n/a obj = self.fixtype(obj)
32n/a # we don't fix the arguments, because UserString can't cope with it
33n/a with self.assertRaises(exc) as cm:
34n/a getattr(obj, methodname)(*args)
35n/a self.assertNotEqual(str(cm.exception), '')
36n/a
37n/a def checkcall(self, object, methodname, *args):
38n/a object = self.fixtype(object)
39n/a # we don't fix the arguments, because UserString can't cope with it
40n/a getattr(object, methodname)(*args)
41n/a
42n/a
43n/aif __name__ == "__main__":
44n/a unittest.main()