@@ -58,6 +58,7 @@ def setUp(self):
5858 self ._box = self ._factory (self ._path )
5959
6060 def tearDown (self ):
61+ self ._box .close ()
6162 self ._delete_recursively (self ._path )
6263
6364 def test_add (self ):
@@ -390,20 +391,22 @@ def _test_flush_or_close(self, method):
390391 self ._box .add (contents [0 ])
391392 self ._box .add (contents [1 ])
392393 self ._box .add (contents [2 ])
394+ oldbox = self ._box
393395 method ()
394396 self ._box = self ._factory (self ._path )
395397 keys = self ._box .keys ()
396398 self .assertEqual (len (keys ), 3 )
397399 for key in keys :
398400 self .assert_ (self ._box .get_string (key ) in contents )
401+ oldbox .close ()
399402
400403 def test_dump_message (self ):
401404 # Write message representations to disk
402405 for input in (email .message_from_string (_sample_message ),
403406 _sample_message , io .StringIO (_sample_message )):
404407 output = io .StringIO ()
405408 self ._box ._dump_message (input , output )
406- self .assert_ (output .getvalue () ==
409+ self .assertEqual (output .getvalue (),
407410 _sample_message .replace ('\n ' , os .linesep ))
408411 output = io .StringIO ()
409412 self .assertRaises (TypeError ,
@@ -694,6 +697,7 @@ def test_directory_in_folder (self):
694697class _TestMboxMMDF (TestMailbox ):
695698
696699 def tearDown (self ):
700+ self ._box .close ()
697701 self ._delete_recursively (self ._path )
698702 for lock_remnant in glob .glob (self ._path + '.*' ):
699703 test_support .unlink (lock_remnant )
@@ -916,6 +920,7 @@ class TestBabyl(TestMailbox):
916920 _factory = lambda self , path , factory = None : mailbox .Babyl (path , factory )
917921
918922 def tearDown (self ):
923+ self ._box .close ()
919924 self ._delete_recursively (self ._path )
920925 for lock_remnant in glob .glob (self ._path + '.*' ):
921926 test_support .unlink (lock_remnant )
0 commit comments