Exemplo n.º 1
0
def test_read_words():
    res_1 = a3.read_words("wordlist1.txt")

    with open("wordlist1.txt") as f:
        words_list = f.readlines()

    assert type(res_1) is list
    assert res_1 == words_list
Exemplo n.º 2
0
 def test_read_words(self):
     # given
     wordsFile = open('wordlist1.txt', 'r')
     wordsList = ['CRUNCHY', 'COWS', 'EAT', 'GRASS']
     # when
     receivedWords = a3.read_words(wordsFile)
     # then
     self.assertEquals(receivedWords, wordsList)
Exemplo n.º 3
0
 def get_words(self):
     '''
     Get user to select word list, read it in via a3 module
     '''
     # TODO:  Actually create a list of words within board (not just number of valid words)
     # TODO (cont'd) (probably need to do this outside of a3.py) - offer an option to show the list
     words_file = askopenfile(mode='r', title='Select word list file')
     self.words = a3.read_words(words_file)
     words_file.close()
     self.set_num_words_rem(a3.num_words_on_board(self.board, self.words))
Exemplo n.º 4
0
    print_score(players)
    print_board(board)
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))

def print_score(players):
    ''' (list of [str, int] list) -> NoneType
    
    Print the scores for each of the players.
    '''
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the word list and board
words_file = askopenfile(mode='r', title='Select word list file')
words = a3.read_words(words_file)
words_file.close()
print (words)
board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board(board_file)
board_file.close()
 
found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Exemplo n.º 5
0
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))


def print_score(players):
    """ (list of [str, int] list) -> NoneType

    Print the scores for each of the players.
    """
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the words list.
words_file = askopenfile(mode='r', title='Select word list file')
words = a3.read_words(words_file)
print(words)
words_file.close()

# Load the board.
board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board(board_file)
print(board)
board_file.close()

found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Exemplo n.º 6
0
    def test_read_words(self):
        words_file = open('wordlist1.txt','r')
        word_list = a3.read_words(words_file)

        for i in range(len(word_list)):
            self.assertEqual(word_list[i],self.word_list[i])
Exemplo n.º 7
0
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))


def print_score(players):
    """ (list of [str, int] list) -> NoneType

    Print the scores for each of the players.
    """
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the words list.
# words_file = askopenfile(mode='r', title='Select word list file')
# print(words_file)
words = a3.read_words('wordlist1.txt')
# words_file.close()

# Load the board.
# board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board('board1.txt')
# board_file.close()

found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Exemplo n.º 8
0
import a3

board_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\board1.txt'
board = open(board_file,'r')

wordlist_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\wordlist1.txt'
word_list = open(wordlist_file,'r')

words = a3.read_words(word_list)

gameboard = a3.read_board(board)

player1 = ['John',4]
player2 = ['Sam',3]
player3 = ['Jenny',5]


players = (player1, player2, player3)







Exemplo n.º 9
0
 def test_get_word_list_contains_CRUNCHY_COWS_EAT_GRASS(self):
     word_list = ['CRUNCHY','COWS','EAT', 'GRASS']
     self.assertEquals(word_list, a3.read_words(open('wordlist1.txt', 'r')))
Exemplo n.º 10
0
import a3

board_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\board1.txt'
board = open(board_file, 'r')

wordlist_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\wordlist1.txt'
word_list = open(wordlist_file, 'r')

words = a3.read_words(word_list)

gameboard = a3.read_board(board)

player1 = ['John', 4]
player2 = ['Sam', 3]
player3 = ['Jenny', 5]

players = (player1, player2, player3)
Exemplo n.º 11
0
 def test01_read_words(self):
     """read words should read from the file and return correct list of words"""
     self.assertEqual(self.wordlist, a3.read_words(self.file_word))