@@ -67,6 +67,8 @@ def removing(f):
67
67
finally :
68
68
if os .path .isfile (f ):
69
69
os .remove (f )
70
+ elif os .path .isdir (f ):
71
+ rmtree (f , ignore_errors = True )
70
72
71
73
72
74
class TestgresTests (unittest .TestCase ):
@@ -436,40 +438,17 @@ def test_dump(self):
436
438
res = node2 .execute (query_select )
437
439
self .assertListEqual (res , [(1 , ), (2 , )])
438
440
439
- dump = node1 .dump (format = 'plain' )
440
- self .assertTrue (os .path .isfile (dump ))
441
- with get_new_node ().init ().start () as node3 :
442
- node3 .restore (filename = dump )
443
- res = node3 .execute (query_select )
444
- self .assertListEqual (res , [(1 , ), (2 , )])
445
- os .remove (dump )
446
-
447
- # take a new dump custom format
448
- dump = node1 .dump (format = 'custom' )
449
- self .assertTrue (os .path .isfile (dump ))
450
- with get_new_node ().init ().start () as node4 :
451
- node4 .restore (filename = dump )
452
- res = node4 .execute (query_select )
453
- self .assertListEqual (res , [(1 , ), (2 , )])
454
- os .remove (dump )
455
-
456
- # take a new dump directory format
457
- dump = node1 .dump (format = 'directory' )
458
- self .assertTrue (os .path .isdir (dump ))
459
- with get_new_node ().init ().start () as node5 :
460
- node5 .restore (filename = dump )
461
- res = node5 .execute (query_select )
462
- self .assertListEqual (res , [(1 , ), (2 , )])
463
- rmtree (dump , ignore_errors = True )
464
-
465
- # take a new dump tar format
466
- dump = node1 .dump (format = 'tar' )
467
- self .assertTrue (os .path .isfile (dump ))
468
- with get_new_node ().init ().start () as node6 :
469
- node6 .restore (filename = dump )
470
- res = node6 .execute (query_select )
471
- self .assertListEqual (res , [(1 , ), (2 , )])
472
- os .remove (dump )
441
+ for format in ['plain' , 'custom' , 'directory' , 'tar' ]:
442
+ with removing (node1 .dump (format = format )) as dump :
443
+ with get_new_node ().init ().start () as node3 :
444
+ if format == 'directory' :
445
+ self .assertTrue (os .path .isdir (dump ))
446
+ else :
447
+ self .assertTrue (os .path .isfile (dump ))
448
+ # restore dump
449
+ node3 .restore (filename = dump )
450
+ res = node3 .execute (query_select )
451
+ self .assertListEqual (res , [(1 , ), (2 , )])
473
452
474
453
def test_users (self ):
475
454
with get_new_node ().init ().start () as node :
0 commit comments