Пример #1
0
    def test_should_get_word(self):
        """
        test running get_word() fcn
        """
        # setup

        # execute
        actual, actual2, actual3 = hangman.get_word(hangman.read_file())

        # assert
        self.assertTrue(len(actual) > 0 and len(actual2) > 0 and len(actual3) > 0)
Пример #2
0
    def test_should_read_file(self):
        """
        test running read_file() fcn
        """
        # setup

        # execute
        actual = hangman.read_file()

        # assert
        self.assertTrue(len(actual) > 0)
Пример #3
0
    def test_should_pick_word(self):
        """
        test running pick_word() fcn
        """
        # setup

        # execute
        actual = hangman.pick_word(hangman.read_file())

        # assert
        self.assertTrue(len(actual) > 0)
Пример #4
0
    def test_previous(self):
        words = hangman.read_file('tests/test_list.txt')
        self.assertEqual(1, len(words))
        self.assertEqual('abc', words[0])

        hangman.random.randint = lambda a, b: 0

        with captured_io(StringIO('a\n')) as (out, err):
            hangman.select_random_word(['abc'])
            hangman.select_random_letter_from('abc')

        output = out.getvalue().strip()
        self.assertEqual("Guess the word: _bc", output)
Пример #5
0
def test_read_file():
    assert read_file('test.txt') == 'test'
Пример #6
0
 def test_step1(self):
     words = hangman.read_file('tests/test_list.txt')
     self.assertEqual(2, len(words))
     self.assertEqual('abc\n', words[0])
     self.assertEqual('def', words[1])
Пример #7
0
 def test_step3_choose_word(self):
     words_list = hangman.read_file('test.txt')
     output = hangman.choose_word(words_list)
     self.assertEqual('Success', output)
Пример #8
0
 def test_step2_read_file_exists(self):
     output = hangman.read_file('test.txt')
     self.assertEqual(['Success\n', 'Success'], output)
Пример #9
0
 def test_step2_read_file_nonexistant(self):
     output = hangman.read_file('testing.txt')
     self.assertEqual(['Failed', 'Malfunction', 'blunder'], output)