TST: be more aggressive in cleanup of temp files + use mktemp instead of mkstemp

pull/163/merge
Yaroslav Halchenko 2013-03-27 23:40:50 -04:00
parent bf4d4af1d4
commit ef3f2b7e99
1 changed files with 8 additions and 1 deletions

View File

@ -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