Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/, pmstestsuite/
Date: Tue, 03 Jan 2012 15:53:10
Message-Id: 07036b5d2418b103a78964ed1fb59c878e37ce04.mgorny@gentoo
1 commit: 07036b5d2418b103a78964ed1fb59c878e37ce04
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 3 10:45:41 2012 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 3 10:45:41 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=07036b5d
7
8 Instantiate the D-Bus handler in CLI.
9
10 ---
11 pmstestsuite/cli.py | 6 +++++-
12 pmstestsuite/library/__init__.py | 6 ++++--
13 pmstestsuite/library/case.py | 17 ++++++++---------
14 3 files changed, 17 insertions(+), 12 deletions(-)
15
16 diff --git a/pmstestsuite/cli.py b/pmstestsuite/cli.py
17 index 8262427..3d4b79e 100644
18 --- a/pmstestsuite/cli.py
19 +++ b/pmstestsuite/cli.py
20 @@ -10,6 +10,7 @@ import gobject
21 from optparse import OptionParser
22
23 from . import PV
24 +from .dbus_handler import DBusHandler
25 from .library import load_library
26 from .repository import NewEbuildRepository
27 from .repository.pms_eclass import get_common_eclass_files
28 @@ -155,9 +156,12 @@ class PMSTestSuiteCLI(object):
29 except (EnvironmentError, KeyError, ValueError) as e:
30 opt.error('Repository open failed: %s' % e)
31
32 + dbus_hdlr = DBusHandler()
33 +
34 try:
35 self.test_library = load_library(opts.library_name,
36 - thorough = opts.thorough, undefined = opts.undefined)
37 + thorough = opts.thorough, undefined = opts.undefined,
38 + dbus_hdlr = dbus_hdlr)
39 except (ImportError, TypeError) as e:
40 opt.error('Test library load failed: %s' % e)
41
42
43 diff --git a/pmstestsuite/library/__init__.py b/pmstestsuite/library/__init__.py
44 index eb5bade..a8adc99 100644
45 --- a/pmstestsuite/library/__init__.py
46 +++ b/pmstestsuite/library/__init__.py
47 @@ -66,7 +66,8 @@ class TestLibrary(ABCObject):
48 mod = __import__(modname, fromlist=[clsname], globals=globals(), level=1)
49 cls = getattr(mod, clsname)
50 for i in cls.inst_all(thorough = self.thorough,
51 - undefined = self.undefined, short_name = t):
52 + undefined = self.undefined, short_name = t,
53 + dbus_hdlr = self.dbus_hdlr):
54 self.tests.append(i)
55 yield i
56
57 @@ -78,8 +79,9 @@ class TestLibrary(ABCObject):
58
59 return len(self.tests)
60
61 - def __init__(self, modname, thorough = False, undefined = False):
62 + def __init__(self, modname, dbus_hdlr, thorough = False, undefined = False):
63 self.modname = modname
64 + self.dbus_hdlr = dbus_hdlr
65 self.thorough = thorough
66 self.undefined = undefined
67
68
69 diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
70 index e007cf6..7cf4b1c 100644
71 --- a/pmstestsuite/library/case.py
72 +++ b/pmstestsuite/library/case.py
73 @@ -9,9 +9,7 @@ import dbus.service
74
75 from abc import ABCMeta, abstractmethod, abstractproperty
76
77 -from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_object_prefix
78 -
79 -dbus_handler = DBusHandler()
80 +from pmstestsuite.dbus_handler import dbus_interface_name, dbus_object_prefix
81
82 # XXX: move to some consts module?
83 phase_func_names = [
84 @@ -244,7 +242,7 @@ class TestCase(dbus.service.Object): # was: ABCObject
85
86 _finalized = False
87
88 - def __init__(self, short_name):
89 + def __init__(self, short_name, dbus_hdlr):
90 """
91 Initialize the test class and the D-Bus interface for it.
92 """
93 @@ -254,7 +252,7 @@ class TestCase(dbus.service.Object): # was: ABCObject
94
95 dbus.service.Object.__init__(
96 self,
97 - dbus_handler.bus,
98 + dbus_hdlr.bus,
99 '%s/%s' % (dbus_object_prefix, self.p.replace('-', '_'))
100 )
101
102 @@ -500,7 +498,7 @@ class EbuildTestCase(TestCase):
103 return (tuple(known_eapis),)
104
105 @classmethod
106 - def inst_all(cls, short_name, thorough = False, undefined = False):
107 + def inst_all(cls, short_name, dbus_hdlr, thorough = False, undefined = False):
108 """
109 Instantiate the test case, choosing a single EAPI from each EAPI group
110 listed in L{supported_eapis}. If thorough mode is enabled, all EAPIs
111 @@ -528,7 +526,8 @@ class EbuildTestCase(TestCase):
112 eapis = [random.choice(x) for x in supported_eapis]
113
114 for eapi in eapis:
115 - yield cls(eapi = eapi, short_name = short_name)
116 + yield cls(eapi = eapi, short_name = short_name,
117 + dbus_hdlr = dbus_hdlr)
118
119 @property
120 def pn(self):
121 @@ -564,7 +563,7 @@ class EbuildTestCase(TestCase):
122 return '%s:%s (%s)' % (self.short_name, self.eapi,
123 self._stripped_docstring)
124
125 - def __init__(self, eapi, short_name):
126 + def __init__(self, eapi, *args, **kwargs):
127 """
128 Instiantate the test case for a particular EAPI.
129
130 @@ -573,7 +572,7 @@ class EbuildTestCase(TestCase):
131 """
132 self.eapi = eapi
133 self.reset()
134 - TestCase.__init__(self, short_name)
135 + TestCase.__init__(self, *args, **kwargs)
136
137 for v in ('ebuild_vars', 'inherits', 'phase_funcs'):
138 setattr(self, v, copy.deepcopy(getattr(self, v)))