cpython: c06b2480766d (original) (raw)

Mercurial > cpython

changeset 96222:c06b2480766d

Issue 22189: Add missing methods to UserString

Raymond Hettinger python@rcn.com
date Fri, 22 May 2015 16:56:32 -0700
parents ecde84db7022
children 830bcf4fb29b
files Lib/collections/__init__.py Lib/test/test_collections.py Misc/NEWS
diffstat 3 files changed, 37 insertions(+), 2 deletions(-)[+] [-] Lib/collections/__init__.py 10 Lib/test/test_collections.py 25 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/collections/init.py +++ b/Lib/collections/init.py @@ -1060,6 +1060,8 @@ class UserString(Sequence): def float(self): return float(self.data) def complex(self): return complex(self.data) def hash(self): return hash(self.data)

def eq(self, string): if isinstance(string, UserString): @@ -1104,9 +1106,13 @@ class UserString(Sequence): rmul = mul def mod(self, args): return self.class(self.data % args)

# the following methods are defined in alphabetical order: def capitalize(self): return self.class(self.data.capitalize())

--- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -12,7 +12,7 @@ import keyword import re import sys import types -from collections import UserDict +from collections import UserDict, UserString, UserList from collections import ChainMap from collections import deque from collections.abc import Awaitable, Coroutine, AsyncIterator, AsyncIterable @@ -24,6 +24,26 @@ from collections.abc import Sequence, Mu from collections.abc import ByteString +class TestUserObjects(unittest.TestCase):

+

+

+ + ################################################################################

ChainMap (helper class for configparser and the string module)

################################################################################ @@ -1848,7 +1868,8 @@ def test_main(verbose=None): NamedTupleDocs = doctest.DocTestSuite(module=collections) test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs, TestCounter, TestChainMap,

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -64,6 +64,10 @@ Library