[conduit: 27/138] Add nicer short descriptions to test output
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit: 27/138] Add nicer short descriptions to test output
- Date: Thu, 21 May 2009 03:29:12 -0400 (EDT)
commit ab518eb58d14c4679e63423bcbe4341e2ed02f81
Author: John Carr <john carr unrouted co uk>
Date: Mon Apr 27 11:50:04 2009 -0700
Add nicer short descriptions to test output
---
test/soup/__init__.py | 15 +++++++++++++++
test/soup/test_dataprovider.py | 13 ++++++++++++-
2 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/test/soup/__init__.py b/test/soup/__init__.py
index 9ee7a8a..535e56d 100644
--- a/test/soup/__init__.py
+++ b/test/soup/__init__.py
@@ -31,6 +31,21 @@ def get_module(name):
class TestCase(unittest.TestCase):
+ def __init__(self, methodName='runTest'):
+ super(TestCase, self).__init__(methodName)
+ self.testMethodName = methodName
+ self.testMethod = getattr(self, methodName)
+
+ @classmethod
+ def name(self):
+ """ Returns the name of the class. We need to override this on generated classes """
+ return self.__class__.__name__
+
+ def shortDescription(self):
+ """ Describe the test that is currently running
+ Returns something like TestClass.test_function: Tests how good Conduit is """
+ return "%s.%s: %s" % (self.name(), self.testMethodName, super(TestCase, self).shortDescription())
+
def setUp(self):
#Set up our own mapping DB so we dont pollute the global one
dbFile = os.path.join(os.environ['TEST_DIRECTORY'],Utils.random_string()+".db")
diff --git a/test/soup/test_dataprovider.py b/test/soup/test_dataprovider.py
index 78939cf..783fa1d 100644
--- a/test/soup/test_dataprovider.py
+++ b/test/soup/test_dataprovider.py
@@ -4,6 +4,10 @@ def make_testcase(wrp):
class TestDataprovider(soup.TestCase):
wrapperclass = wrp
+ @classmethod
+ def name(self):
+ return "TestDataProvider%s" % self.wrapperclass.name()
+
def setUp(self):
super(TestDataprovider, self).setUp()
self.wrapper = self.wrapperclass(self)
@@ -13,21 +17,27 @@ def make_testcase(wrp):
self.dp = None
def test_add(self):
+ """ Should be able to add items """
pass
def test_replace(self):
+ """ Should be able to replace items """
pass
def test_delete(self):
+ """ Should be able to delete items """
pass
def test_refresh(self):
+ """ Refresh shouldnt throw exceptions """
pass
def test_finish(self):
+ """ Should be able to call finish on cold """
self.dp.module.finish(None, None, None)
def test_get_num_items(self):
+ """ Number of items in a fresh dataprovider should be 0 """
self.dp.module.refresh()
assert self.dp.module.get_num_items() == 0
@@ -37,7 +47,8 @@ def make_testcase(wrp):
# Generate TestCase objects for each dataprovider wrapper
self = soup.get_module(__name__)
for wrapper in soup.modules.get_all():
- setattr(self, "TestDataprovider%s" % wrapper.name(), make_testcase(wrapper))
+ testklass = make_testcase(wrapper)
+ setattr(self, testklass.name(), testklass)
# Allow people to run the test case directly
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]