aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-01-03 11:45:41 +0100
committerMichał Górny <mgorny@gentoo.org>2012-01-03 11:45:41 +0100
commit07036b5d2418b103a78964ed1fb59c878e37ce04 (patch)
tree057a3d2725ed90be6c8a9e4029a53135a9662502
parentIntroduce expect_started to fix D-Bus dependency cases. (diff)
downloadpms-test-suite-07036b5d2418b103a78964ed1fb59c878e37ce04.tar.gz
pms-test-suite-07036b5d2418b103a78964ed1fb59c878e37ce04.tar.bz2
pms-test-suite-07036b5d2418b103a78964ed1fb59c878e37ce04.zip
Instantiate the D-Bus handler in CLI.
-rw-r--r--pmstestsuite/cli.py6
-rw-r--r--pmstestsuite/library/__init__.py6
-rw-r--r--pmstestsuite/library/case.py17
3 files changed, 17 insertions, 12 deletions
diff --git a/pmstestsuite/cli.py b/pmstestsuite/cli.py
index 8262427..3d4b79e 100644
--- a/pmstestsuite/cli.py
+++ b/pmstestsuite/cli.py
@@ -10,6 +10,7 @@ import gobject
from optparse import OptionParser
from . import PV
+from .dbus_handler import DBusHandler
from .library import load_library
from .repository import NewEbuildRepository
from .repository.pms_eclass import get_common_eclass_files
@@ -155,9 +156,12 @@ class PMSTestSuiteCLI(object):
except (EnvironmentError, KeyError, ValueError) as e:
opt.error('Repository open failed: %s' % e)
+ dbus_hdlr = DBusHandler()
+
try:
self.test_library = load_library(opts.library_name,
- thorough = opts.thorough, undefined = opts.undefined)
+ thorough = opts.thorough, undefined = opts.undefined,
+ dbus_hdlr = dbus_hdlr)
except (ImportError, TypeError) as e:
opt.error('Test library load failed: %s' % e)
diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
index eb5bade..a8adc99 100644
--- a/pmstestsuite/library/__init__.py
+++ b/pmstestsuite/library/__init__.py
@@ -66,7 +66,8 @@ class TestLibrary(ABCObject):
mod = __import__(modname, fromlist=[clsname], globals=globals(), level=1)
cls = getattr(mod, clsname)
for i in cls.inst_all(thorough = self.thorough,
- undefined = self.undefined, short_name = t):
+ undefined = self.undefined, short_name = t,
+ dbus_hdlr = self.dbus_hdlr):
self.tests.append(i)
yield i
@@ -78,8 +79,9 @@ class TestLibrary(ABCObject):
return len(self.tests)
- def __init__(self, modname, thorough = False, undefined = False):
+ def __init__(self, modname, dbus_hdlr, thorough = False, undefined = False):
self.modname = modname
+ self.dbus_hdlr = dbus_hdlr
self.thorough = thorough
self.undefined = undefined
diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index e007cf6..7cf4b1c 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -9,9 +9,7 @@ import dbus.service
from abc import ABCMeta, abstractmethod, abstractproperty
-from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_object_prefix
-
-dbus_handler = DBusHandler()
+from pmstestsuite.dbus_handler import dbus_interface_name, dbus_object_prefix
# XXX: move to some consts module?
phase_func_names = [
@@ -244,7 +242,7 @@ class TestCase(dbus.service.Object): # was: ABCObject
_finalized = False
- def __init__(self, short_name):
+ def __init__(self, short_name, dbus_hdlr):
"""
Initialize the test class and the D-Bus interface for it.
"""
@@ -254,7 +252,7 @@ class TestCase(dbus.service.Object): # was: ABCObject
dbus.service.Object.__init__(
self,
- dbus_handler.bus,
+ dbus_hdlr.bus,
'%s/%s' % (dbus_object_prefix, self.p.replace('-', '_'))
)
@@ -500,7 +498,7 @@ class EbuildTestCase(TestCase):
return (tuple(known_eapis),)
@classmethod
- def inst_all(cls, short_name, thorough = False, undefined = False):
+ def inst_all(cls, short_name, dbus_hdlr, thorough = False, undefined = False):
"""
Instantiate the test case, choosing a single EAPI from each EAPI group
listed in L{supported_eapis}. If thorough mode is enabled, all EAPIs
@@ -528,7 +526,8 @@ class EbuildTestCase(TestCase):
eapis = [random.choice(x) for x in supported_eapis]
for eapi in eapis:
- yield cls(eapi = eapi, short_name = short_name)
+ yield cls(eapi = eapi, short_name = short_name,
+ dbus_hdlr = dbus_hdlr)
@property
def pn(self):
@@ -564,7 +563,7 @@ class EbuildTestCase(TestCase):
return '%s:%s (%s)' % (self.short_name, self.eapi,
self._stripped_docstring)
- def __init__(self, eapi, short_name):
+ def __init__(self, eapi, *args, **kwargs):
"""
Instiantate the test case for a particular EAPI.
@@ -573,7 +572,7 @@ class EbuildTestCase(TestCase):
"""
self.eapi = eapi
self.reset()
- TestCase.__init__(self, short_name)
+ TestCase.__init__(self, *args, **kwargs)
for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
setattr(self, v, copy.deepcopy(getattr(self, v)))