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