@@ -2534,7 +2534,7 @@ def test_dump_closed_file(self):
2534
2534
f = open (TESTFN , "wb" )
2535
2535
try :
2536
2536
f .close ()
2537
- self .assertRaises (ValueError , pickle .dump , 123 , f )
2537
+ self .assertRaises (ValueError , self .dump , 123 , f )
2538
2538
finally :
2539
2539
os .remove (TESTFN )
2540
2540
@@ -2543,16 +2543,16 @@ def test_load_closed_file(self):
2543
2543
f = open (TESTFN , "wb" )
2544
2544
try :
2545
2545
f .close ()
2546
- self .assertRaises (ValueError , pickle .dump , 123 , f )
2546
+ self .assertRaises (ValueError , self .dump , 123 , f )
2547
2547
finally :
2548
2548
os .remove (TESTFN )
2549
2549
2550
2550
def test_load_from_and_dump_to_file (self ):
2551
2551
stream = io .BytesIO ()
2552
2552
data = [123 , {}, 124 ]
2553
- pickle .dump (data , stream )
2553
+ self .dump (data , stream )
2554
2554
stream .seek (0 )
2555
- unpickled = pickle .load (stream )
2555
+ unpickled = self .load (stream )
2556
2556
self .assertEqual (unpickled , data )
2557
2557
2558
2558
def test_highest_protocol (self ):
@@ -2562,20 +2562,20 @@ def test_highest_protocol(self):
2562
2562
def test_callapi (self ):
2563
2563
f = io .BytesIO ()
2564
2564
# With and without keyword arguments
2565
- pickle .dump (123 , f , - 1 )
2566
- pickle .dump (123 , file = f , protocol = - 1 )
2567
- pickle .dumps (123 , - 1 )
2568
- pickle .dumps (123 , protocol = - 1 )
2569
- pickle .Pickler (f , - 1 )
2570
- pickle .Pickler (f , protocol = - 1 )
2565
+ self .dump (123 , f , - 1 )
2566
+ self .dump (123 , file = f , protocol = - 1 )
2567
+ self .dumps (123 , - 1 )
2568
+ self .dumps (123 , protocol = - 1 )
2569
+ self .Pickler (f , - 1 )
2570
+ self .Pickler (f , protocol = - 1 )
2571
2571
2572
2572
def test_bad_init (self ):
2573
2573
# Test issue3664 (pickle can segfault from a badly initialized Pickler).
2574
2574
# Override initialization without calling __init__() of the superclass.
2575
- class BadPickler (pickle .Pickler ):
2575
+ class BadPickler (self .Pickler ):
2576
2576
def __init__ (self ): pass
2577
2577
2578
- class BadUnpickler (pickle .Unpickler ):
2578
+ class BadUnpickler (self .Unpickler ):
2579
2579
def __init__ (self ): pass
2580
2580
2581
2581
self .assertRaises (pickle .PicklingError , BadPickler ().dump , 0 )
0 commit comments