[TIP] example of Do Fixture in python
Bache, Emily
Emily.Bache at astrazeneca.com
Sun May 20 10:51:53 PDT 2007
Hi,
Thanks for that, it was really helpful to see a real example. I made a couple more modifications to get it to work, since the "Slot" class was not included in the code you sent. I am now going to try to write a test for my code based on it :-)
Cheers,
Emily
-----
from fitLib.ListTree import ListTree, Tree, TreeTypeAdapter
from fitLib.DoFixture import DoFixture
class Slot:
def __init__(self, id_customer):
self.id_customer = id_customer
def getIDCustomer(self):
return self.id_customer
class DoFixtureSample(DoFixture):
_typeDict={
"chargeDollarsAgainstAccount.types":[TreeTypeAdapter, "Integer", "String"],
"abcCustomer.types":[TreeTypeAdapter, "Integer"],
}
def __init__(self, sut=None):
slot = Slot(id_customer=2)
Slot._typeDict = {"getIDCustomer.types":[TreeTypeAdapter]}
DoFixture.__init__(self, sut=slot)
print "HI"
self.x = 0
def chargeDollarsAgainstAccount(self, dollars, account):
print "dollars", dollars
print "account", account
self.x += 1
print "X", self.x
return True
def abcCustomer(self, dollars):
print "IN CHARGE dollars", dollars
return "first customer"
> >
> > Wiki:
> >
> > !|DoFixtureSample|
> > |note|!-<b>-!Testing 123!-</b>-!|
> > |charge|50|dollars against account|89-64P|
> > |charge|75|dollars against account|abc|
> > |charge|100|dollars against account|def|
> > |check|getIDCustomer|2|
> > |charge|100|dollars against account|def|
> > |check|abc|100|customer|first customer|
> >
More information about the testing-in-python
mailing list