From ef3f2b7e999ea4a02890e55e03f03d608d929699 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 27 Mar 2013 23:40:50 -0400 Subject: [PATCH] TST: be more aggressive in cleanup of temp files + use mktemp instead of mkstemp --- testcases/filtertestcase.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/testcases/filtertestcase.py b/testcases/filtertestcase.py index ae0e6525..788c9e9d 100644 --- a/testcases/filtertestcase.py +++ b/testcases/filtertestcase.py @@ -63,6 +63,11 @@ def _killfile(f, name): except: pass + # there might as well be the .bak file + if os.path.exists(name + '.bak'): + _killfile(None, name + '.bak') + + def _sleep_4_poll(): """PollFilter relies on file timestamps - so we might need to sleep to guarantee that they differ @@ -342,7 +347,9 @@ def get_monitor_failures_testcase(Filter_): """Generator of TestCase's for different filters/backends """ - _, testclass_name = tempfile.mkstemp('fail2ban', 'monitorfailures') + # add Filter_'s name so we could easily identify bad cows + testclass_name = tempfile.mktemp( + 'fail2ban', 'monitorfailures_%s' % (Filter_.__name__,)) class MonitorFailures(unittest.TestCase): count = 0