[TIP] example of Do Fixture in python

Grig Gheorghiu grig at gheorghiu.net
Fri May 18 11:38:16 PDT 2007


Sorry, the code had a small error in it (no, I never tested it :-)

Replace abcKaren with abcCustomer on line 9.

Grig

--- Grig Gheorghiu <grig at gheorghiu.net> wrote:

> --- "Bache, Emily" <Emily.Bache at astrazeneca.com> wrote:
> 
> > 
> > If anyone could provide a working example of a DoFixture in python
> I
> > would appreciate it.
> > 
> 
> Examples courtesy of Karen Mishler. Haven't run the code myself, but
> it
> should give you an indication of the syntax required for a DoFixture.
> 
> 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|
> 
> Fixture code is attached (DoFixtureSample.py).
> 
> The PyFIT 0.8a1 docs for DoFixture:
> 
> http://www.agilistas.org/PyFIT_0.8a1_Doc/FitLib_DoFixture.htm
> 
> HTH,
> 
> Grig
> 
> > from fitLib.ListTree import ListTree, Tree, TreeTypeAdapter
> from fitLib.DoFixture import DoFixture
> import Slot
> 
> class DoFixtureSample(DoFixture):
> 
>     _typeDict={
>         "chargeDollarsAgainstAccount.types":[TreeTypeAdapter,
> "Integer", "String"],
>         "abcKaren.types":[TreeTypeAdapter, "Integer"],
>     }
> 
>     def __init__(self, sut=None):
>         slot = Slot.Slot(id_customer=2)
>         Slot.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"
> 




More information about the testing-in-python mailing list