[conduit: 129/138] Further tidy ups for features code
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 129/138] Further tidy ups for features code
- Date: Thu, 21 May 2009 03:37:45 -0400 (EDT)
commit 2b8791a33b293c3ecc11ff25473737ec17f21584
Author: John Carr <john carr unrouted co uk>
Date: Thu May 7 01:40:14 2009 -0700
Further tidy ups for features code
---
test/soup/modules/ipod.py | 12 +-----------
test/soup/utils/test.py | 29 +++++++++++++++++++++++++----
2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/test/soup/modules/ipod.py b/test/soup/modules/ipod.py
index fd4d5f2..b30c12d 100644
--- a/test/soup/modules/ipod.py
+++ b/test/soup/modules/ipod.py
@@ -14,17 +14,7 @@ import conduit.utils as Utils
import uuid
import shutil
-
-class _GpodModule(soup.utils.test.Feature):
-
- def probe(self):
- try:
- import gpod
- return True
- except:
- return False
-
-GpodModule = _GpodModule()
+GpodModule = soup.utils.test.Package("gpod")
class iPodWrapper(object):
def create_dataprovider(self):
diff --git a/test/soup/utils/test.py b/test/soup/utils/test.py
index dc61a07..98d09ea 100644
--- a/test/soup/utils/test.py
+++ b/test/soup/utils/test.py
@@ -164,13 +164,28 @@ class Feature(object):
if not self.available():
raise UnavailableFeature(self)
- @classmethod
- def name(cls):
- return cls.__name__
+ def name(self):
+ return self.__name__
def __str__(self):
return self.name()
+class Package(Feature):
+
+ def __init__(self, *args):
+ super(Package, self).__init__()
+ self.packages = args
+
+ def probe(self):
+ for p in self.packages:
+ try:
+ __import__(p)
+ except:
+ return False
+ return True
+
+ def name(self):
+ return "python dependencies ('%s')" % ", ".join(self.packages)
class _HumanInteractivity(Feature):
@@ -180,6 +195,9 @@ class _HumanInteractivity(Feature):
except:
return False
+ def name(self):
+ return "human button masher"
+
HumanInteractivity = _HumanInteractivity()
@@ -191,6 +209,9 @@ class _Online(Feature):
except:
return False
+ def name(self):
+ return "internet access"
+
Online = _Online()
@@ -351,7 +372,7 @@ class TextTestResult(TestResult):
if len(self.unsupported) > 0:
for feature, count in self.unsupported.iteritems():
- self.stream.writeln("Feature '%s' not available, %d tests skipped" % (feature, count))
+ self.stream.writeln("%s not available, %d tests skipped" % (feature, count))
def printErrorList(self, flavour, errors):
for test, err in errors:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]