[conduit: 38/138] Stub out 'Features'
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 38/138] Stub out 'Features'
- Date: Thu, 21 May 2009 03:30:08 -0400 (EDT)
commit 95c205bb0084cc2a804ec405d2e901847ee73f85
Author: John Carr <john carr unrouted co uk>
Date: Wed Apr 29 07:16:33 2009 -0700
Stub out 'Features'
---
test/soup/__init__.py | 66 ++++++++++++++++++++++++++++++++++++++++++++----
test/soup/soup | 1 -
2 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/test/soup/__init__.py b/test/soup/__init__.py
index 2289b18..2662882 100644
--- a/test/soup/__init__.py
+++ b/test/soup/__init__.py
@@ -110,15 +110,69 @@ class TestCase(unittest.TestCase):
syncManager=self.sync_manager
)
- def is_online(self):
+
+#
+# Custom exceptions
+#
+
+class TestSkipped(Exception):
+ """ Indicate a test was intentionally skipped rather than failed """
+
+
+class UnavailableFeature(Exception):
+ """ A feature required for this test was unavailable """
+
+
+#
+# 'Features'
+# Some tests need things that might not be available, like python gpod, so provide an interface
+# to fail gracefully.
+#
+
+class Feature(object):
+
+ def __init__(self):
+ self._cached = None
+
+ def probe(self):
+ raise NotImplementedError
+
+ def available(self):
+ if self._cached == None:
+ self._cached = self.probe()
+ return self._cached
+
+ def require(self):
+ if not self.available():
+ raise UnavailableFeature
+
+ @classmethod
+ def name(cls):
+ return cls.__name__
+
+ def __str__(self):
+ return self.name()
+
+
+class _HumanInteractivity(Feature):
+
+ def probe(self):
try:
- return os.environ["CONDUIT_ONLINE"] == "TRUE"
- except KeyError:
+ return os.environ["CONDUIT_INTERACTIVE"] == "TRUE"
+ except:
return False
- def is_interactive(self):
+HumanInteractivity = _HumanInteractivity()
+
+
+class _Online(Feature):
+
+ def probe(self):
try:
- return os.environ["CONDUIT_INTERACTIVE"] == "TRUE"
- except KeyError:
+ return os.environ["CONDUIT_ONLINE"] == "TRUE"
+ except:
return False
+Online = _Online()
+
+
diff --git a/test/soup/soup b/test/soup/soup
index c6e1127..682b56f 100755
--- a/test/soup/soup
+++ b/test/soup/soup
@@ -5,7 +5,6 @@ sys.path.insert(0, '..')
os.environ['TEST_DIRECTORY'] = 'tmp'
-import soup
from test_datatypes import *
from test_dataprovider import *
from test_synchronization import *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]