1
1
"""Unit tests for collections.py."""
2
2
3
+ import array
3
4
import collections
4
5
import copy
5
6
import doctest
@@ -469,6 +470,8 @@ def test_module_parameter(self):
469
470
NT = namedtuple ('NT' , ['x' , 'y' ], module = collections )
470
471
self .assertEqual (NT .__module__ , collections )
471
472
473
+ # TODO: RUSTPYTHON
474
+ @unittest .expectedFailure
472
475
def test_instance (self ):
473
476
Point = namedtuple ('Point' , 'x y' )
474
477
p = Point (11 , 22 )
@@ -490,12 +493,8 @@ def test_instance(self):
490
493
self .assertEqual (p ._replace (x = 1 ), (1 , 22 )) # test _replace method
491
494
self .assertEqual (p ._asdict (), dict (x = 11 , y = 22 )) # test _asdict method
492
495
493
- try :
496
+ with self . assertRaises ( TypeError ) :
494
497
p ._replace (x = 1 , error = 2 )
495
- except ValueError :
496
- pass
497
- else :
498
- self ._fail ('Did not detect an incorrect fieldname' )
499
498
500
499
# verify that field string can have commas
501
500
Point = namedtuple ('Point' , 'x, y' )
@@ -547,7 +546,9 @@ def test_odd_sizes(self):
547
546
self .assertEqual (Dot (1 )._replace (d = 999 ), (999 ,))
548
547
self .assertEqual (Dot (1 )._fields , ('d' ,))
549
548
550
- n = support .EXCEEDS_RECURSION_LIMIT
549
+ @support .requires_resource ('cpu' )
550
+ def test_large_size (self ):
551
+ n = support .exceeds_recursion_limit ()
551
552
names = list (set ('' .join ([choice (string .ascii_letters )
552
553
for j in range (10 )]) for i in range (n )))
553
554
n = len (names )
@@ -1150,6 +1151,7 @@ class NonCol(ColImpl):
1150
1151
self .assertFalse (issubclass (NonCol , Collection ))
1151
1152
self .assertFalse (isinstance (NonCol (), Collection ))
1152
1153
1154
+
1153
1155
def test_Iterator (self ):
1154
1156
non_samples = [None , 42 , 3.14 , 1j , b"" , "" , (), [], {}, set ()]
1155
1157
for x in non_samples :
@@ -1985,6 +1987,7 @@ def test_MutableSequence(self):
1985
1987
for sample in [list , bytearray , deque ]:
1986
1988
self .assertIsInstance (sample (), MutableSequence )
1987
1989
self .assertTrue (issubclass (sample , MutableSequence ))
1990
+ self .assertTrue (issubclass (array .array , MutableSequence ))
1988
1991
self .assertFalse (issubclass (str , MutableSequence ))
1989
1992
self .validate_abstract_methods (MutableSequence , '__contains__' , '__iter__' ,
1990
1993
'__len__' , '__getitem__' , '__setitem__' , '__delitem__' , 'insert' )
0 commit comments