Hey, I'm having a lot of confusion getting the unit test working for one of my classes for the Roulette bot I'm working on and would greatly appreciate any advice or help.
Here is the description of what I am trying to do: http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/bin.html . Basically, I have my Bin class working and I am trying to get my BinTest class to do the following: Perform a unit test of the Bin<http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/bin.html#Bin>class. The unit test should create several instances of Outcome<http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/outcome.html#Outcome>, two instances of Bin<http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/bin.html#Bin>and establish that Bin<http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/bin.html#Bin>s can be constructed from the Outcome<http://homepage.mac.com/s_lott/books/oodesign/build-python/html/roulette/outcome.html#Outcome> s. While I would greatly appreciate any pointers in fixing my mistakes, I would also greatly appreciate any pointers telling me what exactly it is that I do not yet understand. Thanks a bunch, my code is below. Here is my Bin class: from Outcome import * class Bin: def __init__(self, *outcomes): self.outcomes = outcomes def add(self, outcome): self.outcomes += outcome return self.outcomes def __str__(self): return (', '.join( map(str,self.outcomes))) Here is the code for my BinTest class: import Outcome import Bin class BinTest: def __init__(self): pass def create_Outcome(outcome): o1 = Outcome(outcome) #creates two instances of Bin def create_Bin(): b1 = Bin(("Red", 5), ("Black", 17),("Red", 5)) b2 = Bin(("00-0-1-2-3"), ("00")) #establishes that Bin can be constructed from Outcome def construct_Bin_from_Outcome(): b3 = Bin(o2) b4 = Bin(o4) b5 = Bin(o1) def main(): bin_test1 = BinTest() bin_test1.create_Outcome() #create_Outcome("Red", 5) #create_Outcome("Black", 17) #create_Outcome("Red", 5) #create_Outcome("00-0-1-2-3") #create_Outcome("00") print("o2 is ", o2) print("o3 is ", o3) print("o4 is ", o4) print("o5 is ", o5) print("b1 is ", b1) print("b2 is ", b2) print("b3 is ", b3) print("b4 is ", b4) print("b5 is ", b5) if __name__ == "__main__": main()
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
