Exemplo n.º 1
0
 def test_new_game2(
         self):  #checks that the function not works with unfull list
     deck1 = DeckOfCards()
     deck1.listcards.pop()
     deck2 = deck1.listcards.copy()
     deck1.newGame()
     self.assertTrue(deck1.listcards[0] == deck2[0])
Exemplo n.º 2
0
 def test_deal_one1(
         self):  #checks that function not works with over than full list
     deck1 = DeckOfCards()
     deck1.listcards = []
     for i in range(53):
         card1 = Card(i + 1, "Heart")
         deck1.listcards.append(card1)
     self.assertTrue(deck1.dealOne() != True)
Exemplo n.º 3
0
 def test_deal_one(self):  #checks that function not works with empty list
     # with patch ('games.cards.DeckOfCards.DeckOfCards.dealOne') as mock_dealone:
     #     mock_dealone.return_value = 5
     #     deck1 = DeckOfCards()
     #     self.assertTrue(deck1.dealOne(),5)
     deck1 = DeckOfCards()
     deck1.listcards = []
     self.assertFalse(deck1.dealOne())
Exemplo n.º 4
0
 def test_shuffle(self):
     deck1 = DeckOfCards()
     deck2 = deck1.listcards.copy()
     deck1.newGame()
     break1 = 0
     for i in range(len(deck1.listcards)):
         if deck1.listcards[i] != deck2[i]:
             break1 += 1
             break
     self.assertTrue(break1 == 1)
Exemplo n.º 5
0
 def test_deal_one2(
     self
 ):  #checks that function not work with value that isn't type 'Card'
     deck1 = DeckOfCards()
     deck1.listcards = []
     for i in range(50):
         card1 = Card(i + 1, "Heart")
         deck1.listcards.append(card1)
     deck1.listcards.append(4)
     self.assertFalse(deck1.dealOne())
Exemplo n.º 6
0
 def test_new_game(
         self):  #checks that the function suffle the valid list (52 values)
     deck1 = DeckOfCards()
     deck2 = deck1.listcards.copy()
     deck1.newGame()
     break1 = 0
     for i in range(len(deck1.listcards)):
         if deck1.listcards[i] != deck2[i]:
             break1 += 1
             break
     self.assertTrue(break1 == 1)
Exemplo n.º 7
0
 def test_deal_one3(self):  #checks that the function works with valid list
     deck1 = DeckOfCards()
     deck1.listcards = []
     for i in range(50):
         card1 = Card(1, "Heart")
         deck1.listcards.append(card1)
     length = len(deck1.listcards)
     print(length)
     deck1.dealOne()
     print(len(deck1.listcards))
     self.assertTrue(len(deck1.listcards) == length - 1)
Exemplo n.º 8
0
 def __init__(self, numofcards):
     self.listofcards = DeckOfCards().listcards
     self.numofcards = numofcards
     if type(numofcards) != int:
         raise ValueError("inalid numofcards type.")
     if self.numofcards > 5 or self.numofcards < 0:
         self.numofcards = 5
     self.players = []
     for i in range(0, 4, 1):
         player = Player(input("enter name of player"),
                         input("enter amount of money"))
         if player.name == "":
             player.name = "Player" + str(i + 1)
         if player.money < 5000 or player.money > 10000:
             player.money = 5000
         self.players.append(player)
Exemplo n.º 9
0
 def test_show(self):  #checks the function not work with invalid values
     deck1 = DeckOfCards()
     deck1.listcards = []
     deck1.listcards.append(5)
     self.assertTrue(deck1.show() == "False")
 def setUp(self):
     self.deck_cards = DeckOfCards()
     self.deck_shuffle = DeckOfCards()