From 6f58b9a9bc5a1e7314336caec10acabe751d1f94 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Mon, 2 Jan 2012 22:29:24 +0100 Subject: Integrate the D-Bus object with base D-Bus test case class. --- pmstestsuite/library/case.py | 4 ++-- pmstestsuite/library/standard/dbus_case.py | 32 ++++++++++-------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py index a5817fb..614a500 100644 --- a/pmstestsuite/library/case.py +++ b/pmstestsuite/library/case.py @@ -1,5 +1,5 @@ # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny +# (c) 2011-2012 Michał Górny # Released under the terms of the 2-clause BSD license. import copy, itertools, random, re @@ -227,7 +227,7 @@ class NotEqualAssertionResult(EqualAssertionResult): return '%s != %s' % (self.actual, repr(self._expect)) -class TestCase(ABCObject): +class TestCase(object): # was: ABCObject """ Base class for a test case. diff --git a/pmstestsuite/library/standard/dbus_case.py b/pmstestsuite/library/standard/dbus_case.py index 672ace5..ac9c4d1 100644 --- a/pmstestsuite/library/standard/dbus_case.py +++ b/pmstestsuite/library/standard/dbus_case.py @@ -1,5 +1,5 @@ # vim:fileencoding=utf-8 -# (c) 2011 Michał Górny +# (c) 2011-2012 Michał Górny # Released under the terms of the 2-clause BSD license. import dbus.service @@ -13,30 +13,26 @@ from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_obj dbus_handler = DBusHandler() -class RunningTest(dbus.service.Object): - """ A class encapsulating a running test. """ +class DBusBaseTestCase(dbus.service.Object): + """ A base D-Bus test case class. """ - def __init__(self, test): + def __init__(self): """ - Initialize the D-Bus object for the test. - - @param test: the test - @type test: L{TestCase} + Initialize the D-Bus interface for the test. """ - self.test = test self.reset() dbus.service.Object.__init__( self, dbus_handler.bus, - '%s/%s' % (dbus_object_prefix, test.p.replace('-', '_')) + '%s/%s' % (dbus_object_prefix, self.p.replace('-', '_')) ) def reset(self): """ Reset test results. """ - self.test.dbus_output = [] - self.test.dbus_started = False + self.dbus_output = [] + self.dbus_started = False @dbus.service.method( dbus_interface=dbus_interface_name, @@ -45,7 +41,7 @@ class RunningTest(dbus.service.Object): """ Notify the test suite that a particular test has been started. """ - self.test.dbus_started = True + self.dbus_started = True @dbus.service.method( dbus_interface=dbus_interface_name, @@ -57,13 +53,7 @@ class RunningTest(dbus.service.Object): @param l: result string @type l: C{dbus.UTF8String} """ - self.test.dbus_output.append(str(l)) - -class DBusBaseTestCase(object): - """ A base D-Bus test case class. """ - - def __init__(self): - self._dbusobj = RunningTest(self) + self.dbus_output.append(str(l)) def _finalize(self): """ @@ -92,7 +82,7 @@ class DBusBaseTestCase(object): def _pop_dbus_output(self): ret = self.dbus_output - self._dbusobj.reset() + self.reset() return ret def check_result(self, pm): -- cgit v1.2.3-65-gdbad