[Checkins] SVN: z3c.testing/trunk/ Do some ``InterfaceBaseTest`` attributes to be able to write less code
Adam Groszer
agroszer at gmail.com
Wed Feb 17 05:34:36 EST 2010
Log message for revision 109089:
Do some ``InterfaceBaseTest`` attributes to be able to write less code
Changed:
U z3c.testing/trunk/CHANGES.txt
U z3c.testing/trunk/src/z3c/testing/app.py
-=-
Modified: z3c.testing/trunk/CHANGES.txt
===================================================================
--- z3c.testing/trunk/CHANGES.txt 2010-02-17 03:41:32 UTC (rev 109088)
+++ z3c.testing/trunk/CHANGES.txt 2010-02-17 10:34:35 UTC (rev 109089)
@@ -5,7 +5,11 @@
0.3.2 (unreleased)
------------------
-- Nothing changed yet.
+- Do some ``InterfaceBaseTest`` attributes to be able to write less code:
+ - ``iface`` provide the interface here
+ - ``klass`` provide the class here
+ - ``pos`` provide the positional arguments here
+ - ``kws`` provide the keyword arguments here
0.3.1 (2009-12-26)
Modified: z3c.testing/trunk/src/z3c/testing/app.py
===================================================================
--- z3c.testing/trunk/src/z3c/testing/app.py 2010-02-17 03:41:32 UTC (rev 109088)
+++ z3c.testing/trunk/src/z3c/testing/app.py 2010-02-17 10:34:35 UTC (rev 109089)
@@ -28,35 +28,47 @@
class TestCase(unittest.TestCase):
+ iface = None
+ klass = None
+ pos = marker_pos
+ kws = marker_kws
+
def getTestInterface(self):
+ if self.iface is not None:
+ return self.iface
+
msg = 'Subclasses has to implement getTestInterface()'
raise NotImplementedError, msg
def getTestClass(self):
+ if self.klass is not None:
+ return self.klass
+
raise NotImplementedError, 'Subclasses has to implement getTestClass()'
def getTestPos(self):
- return marker_pos
+ return self.pos
def getTestKws(self):
- return marker_kws
-
+ return self.kws
+
def makeTestObject(self, object=None, *pos, **kws):
# provide default positional or keyword arguments
- if self.getTestPos() is not marker_pos and not pos:
- pos = self.getTestPos()
+ ourpos = self.getTestPos()
+ if ourpos is not marker_pos and not pos:
+ pos = ourpos
- if self.getTestKws() is not marker_kws and not kws:
- kws = self.getTestKws()
-
+ ourkws = self.getTestKws()
+ if ourkws is not marker_kws and not kws:
+ kws = ourkws
+
testclass = self.getTestClass()
if object is None:
- # a class instance itself is the object to be tested.
+ # a class instance itself is the object to be tested.
return testclass(*pos, **kws)
-
else:
- # an adapted instance is the object to be tested.
+ # an adapted instance is the object to be tested.
return testclass(object, *pos, **kws)
@@ -74,11 +86,11 @@
def test_verifyClass(self):
# class test
- self.assert_(verifyClass(self.getTestInterface(), self.getTestClass()))
+ self.assert_(verifyClass(self.getTestInterface(), self.getTestClass()))
def test_verifyObject(self):
# object test
- self.assert_(verifyObject(self.getTestInterface(),
+ self.assert_(verifyObject(self.getTestInterface(),
self.makeTestObject()))
More information about the checkins
mailing list