File tree 1 file changed +6
-10
lines changed
1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -2370,14 +2370,9 @@ def test_expandtabs_optimization(self):
2370
2370
self .assertIs (s .expandtabs (), s )
2371
2371
2372
2372
def test_raiseMemError (self ):
2373
- if struct .calcsize ('P' ) == 8 :
2374
- # 64 bits pointers
2375
- ascii_struct_size = 48
2376
- compact_struct_size = 72
2377
- else :
2378
- # 32 bits pointers
2379
- ascii_struct_size = 24
2380
- compact_struct_size = 36
2373
+ null_byte = 1
2374
+ ascii_struct_size = sys .getsizeof ("a" ) - len ("a" ) - null_byte
2375
+ compact_struct_size = sys .getsizeof ("\xff " ) - len ("\xff " ) - null_byte
2381
2376
2382
2377
for char in ('a' , '\xe9 ' , '\u20ac ' , '\U0010ffff ' ):
2383
2378
code = ord (char )
@@ -2395,8 +2390,9 @@ def test_raiseMemError(self):
2395
2390
# be allocatable, given enough memory.
2396
2391
maxlen = ((sys .maxsize - struct_size ) // char_size )
2397
2392
alloc = lambda : char * maxlen
2398
- self .assertRaises (MemoryError , alloc )
2399
- self .assertRaises (MemoryError , alloc )
2393
+ with self .subTest (char = char ):
2394
+ self .assertRaises (MemoryError , alloc )
2395
+ self .assertRaises (MemoryError , alloc )
2400
2396
2401
2397
def test_format_subclass (self ):
2402
2398
class S (str ):
You can’t perform that action at this time.
0 commit comments