Browse Source

renamed tests to tests.txt and did some formatting

master
Steinadler 3 months ago
parent
commit
a2fcec03f2
3 changed files with 50 additions and 17 deletions
  1. 0
    7
      clean_input.py
  2. 9
    4
      quartett.py
  3. 41
    6
      tests.txt

+ 0
- 7
clean_input.py View File

@@ -141,10 +141,3 @@ def restart():
141 141
     print(
142 142
         "---------------------\nSpiel wird neu gestartet...\n---------------------")
143 143
     quartett.central_function()
144
-
145
-
146
-
147
-
148
-
149
-
150
-

+ 9
- 4
quartett.py View File

@@ -86,7 +86,8 @@ def round(card_stack, players_with_cards, players, active, complete_card_stack,
86 86
                 print('Folgende Spieler stehen zur Verfügung:')
87 87
                 print(players_without_active)
88 88
                 chosen_player = players.index(clean_input.io_str(
89
-                    'Welchen Spieler möchtest du nach einer Karte fragen? ', players_without_active))
89
+                    'Welchen Spieler möchtest du nach einer Karte fragen? ',
90
+                    players_without_active))
90 91
             else:
91 92
                 chosen_player = 1
92 93
 
@@ -341,7 +342,7 @@ def the_winner_is(players_with_cards, players):
341 342
     temp = 1
342 343
     winners = []
343 344
 
344
-    # all potential winners are saved in the winners-list 
345
+    # all potential winners are saved in the winners-list
345 346
     # (in case there is more than one)
346 347
     for i in range(len(players)):
347 348
         winners.append(0)
@@ -354,7 +355,7 @@ def the_winner_is(players_with_cards, players):
354 355
         if temp == dropped_quartets:
355 356
             winners[i] = dropped_quartets
356 357
 
357
-    # winners then functions as a template 
358
+    # winners then functions as a template
358 359
     # to print all the players' names who have won
359 360
     print("")
360 361
     for i in range(len(winners)):
@@ -368,6 +369,10 @@ def the_winner_is(players_with_cards, players):
368 369
 
369 370
 
370 371
 def end_screen():
372
+    """
373
+    Shows the end screen.
374
+    :return: None
375
+    """
371 376
     clean_input.io_str("Möchten Sie das Spiel beenden oder ein neues Spiel starten? "
372 377
                        "Drücken Sie 'q' zum Beenden oder 'r', "
373 378
                        "um ein neues Spiel zu starten...", [])
@@ -377,5 +382,5 @@ def end_screen():
377 382
 if __name__ == "__main__":
378 383
     # remove end_screen() from the_winner_is() if you want to run tests
379 384
     # import doctest
380
-    # doctest.testfile("tests")
385
+    # doctest.testfile("tests.txt")
381 386
     central_function()

tests → tests.txt View File

@@ -2,9 +2,25 @@
2 2
 >>> import clean_input as c
3 3
 
4 4
 
5
->>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number': '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0', 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0', 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1', 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0', 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
6
-... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'}, {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'}, {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'}, {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'}, {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'}, {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}], 'quartet': 1},
7
-... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'}, {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'}, {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'}, {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'}, {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'}, {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
5
+>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
6
+... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
7
+... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
8
+... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
9
+... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
10
+... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
11
+... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
12
+... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
13
+... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
14
+... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
15
+... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
16
+... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
17
+... 'quartet': 1},
18
+... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
19
+... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
20
+... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
21
+... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
22
+... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
23
+... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
8 24
 
9 25
 
10 26
 1. pretty_print_deck(players_with_cards, player)
@@ -116,21 +132,40 @@ True
116 132
 
117 133
 Positivtests:
118 134
 
119
->>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number': '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0', 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0', 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1', 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0', 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
120
-... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'}, {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'}, {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'}, {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'}, {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'}, {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}], 'quartet': 1},
121
-... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'}, {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'}, {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'}, {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'}, {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'}, {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
135
+>>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
136
+... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
137
+... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
138
+... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
139
+... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
140
+... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
141
+... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
142
+... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
143
+... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
144
+... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
145
+... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
146
+... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
147
+... 'quartet': 1},
148
+... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
149
+... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
150
+... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
151
+... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
152
+... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
153
+... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
122 154
 
123 155
 >>> players = ["player0", "player1", "player2"]
124 156
 >>> q.the_winner_is(players_with_cards, players)
157
+<BLANKLINE>
125 158
 player2 hat das Spiel gewonnen!
126 159
 
127 160
 >>> players_with_cards[1]["quartet"] = 2
128 161
 >>> q.the_winner_is(players_with_cards, players)
162
+<BLANKLINE>
129 163
 player1 hat das Spiel gewonnen!
130 164
 player2 hat das Spiel gewonnen!
131 165
 
132 166
 >>> players_with_cards[0]["quartet"] = 2
133 167
 >>> q.the_winner_is(players_with_cards, players)
168
+<BLANKLINE>
134 169
 Du hast das Spiel gewonnen!
135 170
 player1 hat das Spiel gewonnen!
136 171
 player2 hat das Spiel gewonnen!

Loading…
Cancel
Save