summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@collabora.com>2012-06-18 18:10:03 -0400
committerThibault Saunier <thibault.saunier@collabora.com>2012-06-21 10:00:09 -0400
commit345a3e8600b0948b348edf13e800e70e3230e97e (patch)
treee5d782ef276c4cb212785089c37137b6c5df0998
parent64627f13d676ccc45e70666b888ad63c2748ef2b (diff)
insanity: Enhance Test teardown subclassing mecanisme
This way the method from the super class can execute code before and after calling subclasses vmethod
-rw-r--r--insanity/dbustest.py4
-rw-r--r--insanity/test.py18
2 files changed, 17 insertions, 5 deletions
diff --git a/insanity/dbustest.py b/insanity/dbustest.py
index 4b19efc..ea00229 100644
--- a/insanity/dbustest.py
+++ b/insanity/dbustest.py
@@ -215,7 +215,7 @@ class DBusTest(Test, dbus.service.Object):
return False
return self.callRemoteStart()
- def tearDown(self):
+ def tearDownVmethod(self):
info("uuid:%s", self.uuid)
# FIXME : tear down the other process gracefully
# by first sending it the termination remote signal
@@ -247,8 +247,6 @@ class DBusTest(Test, dbus.service.Object):
self.extraInfo("subprocess-return-code", self._returncode)
self.validateChecklistItem("subprocess-exited-normally", self._returncode == 0)
- Test.tearDown(self)
-
def stop(self):
info("uuid:%s", self.uuid)
self.callRemoteStop()
diff --git a/insanity/test.py b/insanity/test.py
index f110bad..57f13b7 100644
--- a/insanity/test.py
+++ b/insanity/test.py
@@ -376,15 +376,26 @@ class Test(gobject.GObject):
self._monitorinstances.append(instance)
return True
+ def tearDownVmethod(self):
+ """
+ Virtual method for subclasses to implement teardown
+
+ You should chain up to the parent function at the BEGINNING
+ of your method
+ """
+ pass
+
def tearDown(self):
"""
Clear test
- If you implement this method, you need to chain up to the
- parent class' tearDown() at the END of your method.
+ Subclassed should not implement this method directly but rather
+ the tearDownVmethod instead
Your teardown MUST happen in a synchronous fashion.
"""
+ self.tearDownVmethod()
+
stoptime = time.time()
if self._asynctimeoutid:
gobject.source_remove(self._asynctimeoutid)
@@ -406,8 +417,11 @@ class Test(gobject.GObject):
stoptime, self._teststarttime)
self.extraInfo("test-total-duration",
int((stoptime - self._teststarttime) * 1000))
+
+ # Finaly clear monitors
for instance in self._monitorinstances:
instance.tearDown()
+
self.emit("done")
def stop(self):