Skip to content

Commit 92dfb3a

Browse files
committed
clean data after run test
1 parent 4261d5e commit 92dfb3a

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

tests/helpers/ptrack_helpers.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# you need os for unittest to work
22
import os
3+
import gc
34
from sys import exit, argv, version_info
45
import subprocess
56
import shutil
@@ -1515,29 +1516,24 @@ def get_version(self, node):
15151516
def get_bin_path(self, binary):
15161517
return testgres.get_bin_path(binary)
15171518

1519+
def clean_all(self):
1520+
for o in gc.get_referrers(testgres.PostgresNode):
1521+
if o.__class__ is testgres.PostgresNode:
1522+
o.cleanup()
1523+
15181524
def del_test_dir(self, module_name, fname, nodes=[]):
15191525
""" Del testdir and optimistically try to del module dir"""
15201526
try:
1521-
testgres.clean_all()
1522-
except:
1523-
pass
1524-
1525-
if not nodes:
1526-
nodes = self.nodes
1527-
for node in list(nodes):
1528-
try:
1529-
if node.status() == 0:
1530-
node.stop()
1531-
except:
1532-
raise
1533-
finally:
1534-
if node in self.nodes:
1535-
self.nodes.remove(node)
1527+
self.clean_all()
1528+
except Exception as e:
1529+
raise e
15361530

15371531
shutil.rmtree(
15381532
os.path.join(
15391533
self.tmp_path,
1540-
module_name
1534+
module_name,
1535+
fname,
1536+
"backup"
15411537
),
15421538
ignore_errors=True
15431539
)

0 commit comments

Comments
 (0)