-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_check.py
38 lines (33 loc) · 1.16 KB
/
test_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3 east eats seat teas
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 14 11:52:21 2017
@author: tcs-user
"""
from itertools import combinations
from Hangman1 import check, DICT
def test_check():
game_situations = []
for word in DICT:
for i in range(4):
current = word
comb = combinations(word, i)
for letters in comb:
for letter in letters:
current = current.replace(letter, '*')
if current not in game_situations:
game_situations.append(current)
alph = 'abcdefghijklmnopqrstuvwxyz'
for i in range(4):
for word in DICT:
for lett in alph:
for guess in game_situations:
if lett not in word:
assert check(lett, guess, word,
i) == (guess, word, i + 1)
else:
ind = word.find(lett)
guess1 = guess[:ind] + lett + guess[ind + 1:]
assert check(lett, guess, word,
i) == (guess1, word, i)
test_check()