From 0f85ebd9d89097d2f70f301c0b800b7ae8e433e8 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 21 Feb 2012 09:36:04 +0100 Subject: [PATCH] Fix asyncnotifier unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 :). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- test/ganeti.asyncnotifier_unittest.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/ganeti.asyncnotifier_unittest.py b/test/ganeti.asyncnotifier_unittest.py index 9acb60cf3..0a376e625 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 -- GitLab