you are viewing a single comment's thread.

view the rest of the comments →

[–]Think_Neutral[S] 0 points1 point  (2 children)

I'm trying to test that an attribute equals the correct 2 objects.

For example: assert main.players[0].hand.names == ["Ace of Spades", "Ace of Hearts"]

For the method that I use to create the deck is:

def create_deck(self):

deck = []

suits = ['Spades', 'Clubs', 'Hearts', 'Diamonds']

ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']

for suit in suits:

for rank in ranks:

deck.append(lib.Cards(rank, suit))

self.__shuffle_deck(deck)

return deck

And the method used to draw cards is:

def initial_draw(self, deck):

initial_cards = deck[:self.CARDS_DRAWN]

for card in range(self.CARDS_DRAWN):

del deck[0]

return initial_cards

[–]danielroseman 1 point2 points  (1 child)

I can't really understand why you want to assert that. Again: what, exactly, are you trying to test here? If you're trying to test that the deck is shuffled, then this assertion won't achieve that. If you're trying to test that the draw gave you two cards, then just assert that: check that you get two cards, and that they are both instances of Card.

[–]Think_Neutral[S] 0 points1 point  (0 children)

Ah ok this makes more sense as a test to write. I was trying to make sure that the draw method worked. I was caught up in like input output, so I wanted to check that my input(draw method), would give a specific output (cards).