On my workstation, if I run the following two tests in this exact
order:

- TestSingleFileEventHandler.testError
- TestSingleFileEventHandler.testReplace

the second test will fail, because there is no "unregister" of
previous tests (and the poll() done by asyncore will fire on the
previous files which are now removed, etc. etc.).

While investigating this, I realised that we don't do any cleanup of
the various handlers/notifiers we setup for this test, so if we simply
add a proper cleanup, the tests will work nicely (in any order :).
---
 test/ganeti.asyncnotifier_unittest.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/test/ganeti.asyncnotifier_unittest.py 
b/test/ganeti.asyncnotifier_unittest.py
index 9acb60c..0a376e6 100755
--- a/test/ganeti.asyncnotifier_unittest.py
+++ b/test/ganeti.asyncnotifier_unittest.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
 
-# Copyright (C) 2010 Google Inc.
+# Copyright (C) 2010, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -73,6 +73,15 @@ class TestSingleFileEventHandler(testutils.GanetiTestCase):
     # TERM notifier is enabled by default, as we use it to get out of the loop
     self.ihandler[self.NOTIFIER_TERM].enable()
 
+  def tearDown(self):
+    # disable the inotifiers, before removing the files
+    for i in self.ihandler:
+      i.disable()
+    testutils.GanetiTestCase.tearDown(self)
+    # and unregister the fd's being polled
+    for n in self.notifiers:
+      n.del_channel()
+
   class OnInotifyCallback:
     def __init__(self, testobj, i):
       self.testobj = testobj
-- 
1.7.7.3

Reply via email to