Exemple #1
0
def place_word(word, row, column, direction):
    if direction == "H":
        if crossword.fit_word_horizontal(row, column, word):
            crossword.put_word(word, row, column, direction)
    elif direction == "V":
        if crossword.fit_word_vertical(row, column, word):
            crossword.put_word(word, row, column, direction)
Exemple #2
0
 def test_fit_word_vertically_doesnt_fit_grid(self):
     new_puzzle = xword.puzzle[:]
     if xword.fit_word_vertical(5, 0, 'program'):
         xword.put_word('program', 5, 0, 'V')
     self.assertEqual(xword.puzzle, new_puzzle,
                      'program does not fit so puzzle should not change')
     xword.puzzle = xword.puzzle_copy[:]  # just in case
Exemple #3
0
 def test_fit_word_vertically_another_word_there(self):
     new_puzzle = xword.puzzle[:]
     if xword.fit_word_vertical(0, 5, 'something'):
         xword.put_word('something', 0, 5, 'V')
     self.assertEqual(xword.puzzle, new_puzzle,
                      'testing is already in that location')
     xword.puzzle = xword.puzzle_copy[:]  # just in case
Exemple #4
0
 def try_put_word_horizontally_another_word_there(self):
     new_puzzle = xword.puzzle[:]
     if xword.fit_word_horizontal(5, 0, 'krypton'):
         xword.put_word('krypton', 5, 0, 'H')
     self.assertEqual(xword.puzzle, new_puzzle,
                      'the word python is already in that location')
     xword.puzzle = xword.puzzle_copy[:]  # just in case
Exemple #5
0
 def try_put_word_horizontally_doesnt_fit_grid(self):
     new_puzzle = xword.puzzle[:]
     if xword.fit_word_horizontal(4, 5, 'integration'):
         xword.put_word('integration', 4, 5, 'H')
     self.assertEqual(
         xword.puzzle, new_puzzle,
         'integration does not fit so puzzle should not change')
     xword.puzzle = xword.puzzle_copy[:]  # just in case
Exemple #6
0
 def test_put_word_vertically(self):
     if xword.fit_word_vertical(2, 9, 'no'):
         xword.put_word('no', 2, 9, 'V')
     new_puzzle = [
         '     t        ', '     e        ', '    assignment',
         '     t   o    ', '     i        ', 'python        ',
         '     g        '
     ]
     self.assertEqual(xword.puzzle, new_puzzle, 'no should fit in 2, 9')
     xword.puzzle = xword.puzzle_copy[:]
Exemple #7
0
 def test_put_word_horizontally(self):
     if xword.fit_word_horizontal(6, 5, 'get'):
         xword.put_word('get', 6, 5, 'H')
     new_puzzle = [
         '     t        ', '     e        ', '    assignment',
         '     t        ', '     i        ', 'python        ',
         '     get      '
     ]
     self.assertEqual(xword.puzzle, new_puzzle, 'get should fit in 6, 5')
     xword.puzzle = xword.puzzle_copy[:]
Exemple #8
0
def place_word(word, row, column, direction):
    if word_fits(word, row, column, direction):
        xword.put_word(word, row, column, direction)
Exemple #9
0
assert isinstance(result, str), \
    '''char_above should return an str, but returned {0}''' \
    .format(type(result))

# Type check crossword.char_below
result = crossword.char_below(0, 0)
assert isinstance(result, str), \
    '''char_below should return an str, but returned {0}''' \
    .format(type(result))

# Type check crossword.fit_char_horizontal
result = crossword.fit_char_horizontal(0, 0, "s")
assert isinstance(result, bool), \
    '''fit_char_horizontal should return an bool, but returned {0}''' \
    .format(type(result))

# Type check crossword.fit_char_vertical
result = crossword.fit_char_vertical(0, 0, "t")
assert isinstance(result, bool), \
    '''fit_char_vertical should return an bool, but returned {0}''' \
    .format(type(result))

# Type check crossword.put_word(word, row, col, direction)
result = crossword.put_word("p", 0, 0, "V")
assert isinstance(result, type(None)), \
    '''put_word should return a NoneType, but returned {0}''' \
    .format(type(result))

print("If you see this (and no error messages above it), \
then you have passed the type checker")