def test_guess_incorrect(self, mock_input):
        output, value = get_function_output(lambda: self.load())
        expect = """Turn 1
You missed my battleship!
O O O O O
O O X O O
O O O O O
O O O O O
O O O O O
Turn 2
You guessed that one already.
O O O O O
O O X O O
O O O O O
O O O O O
O O O O O
Turn 3
You guessed that one already.
O O O O O
O O X O O
O O O O O
O O O O O
O O O O O
Turn 4
You guessed that one already.
Game Over
"""
        self.assertEqual(expect, output)
    def test_invalid(self, mock_input):
        output, value = get_function_output(lambda: self.load())
        expect = """Turn 1
Oops, that's not even in the ocean.
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Turn 2
Oops, that's not even in the ocean.
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Turn 3
Oops, that's not even in the ocean.
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Turn 4
Oops, that's not even in the ocean.
Game Over
"""
        self.assertEqual(expect, output)
Ejemplo n.º 3
0
    def test_guess_correct(self, mock_input):
        output, value = get_function_output(lambda: self.load())
        expect = """1
1
Turn 1
Congratulations! You sank my battleship!
"""
        self.assertEqual(expect, output)
Ejemplo n.º 4
0
    def testOutput(self):
        output, value = get_function_output(lambda: print_board(board))
        expected = """['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
"""
        self.assertEqual(expected, output)
    def test_guess_incorrect(self, mock_input):
        output, value = get_function_output(lambda: self.load())
        expect = """1
1
You missed my battleship!
O O O O O
O O X O O
O O O O O
O O O O O
O O O O O
"""
        self.assertEqual(expect, output)
    def test(self, mock_input):
        def load():
            if is_answer:
                from lab12.ch012_t08_it_is_debugging_ans import ship_row, ship_col
            else:
                from lab12.ch012_t08_it_is_debugging import ship_row, ship_col
            return f"""{ship_row}
{ship_col}
"""

        output, value = get_function_output(load)
        self.assertEqual(output, value)
 def test_n(self, mock_input):
     output, value = get_function_output(lambda: self.load())
     expect = ""
     self.assertEqual(expect, output)
 def test_guess_incorrect(self, mock_input):
     output, value = get_function_output(load)
     self.assertFalse("Congratulations! You sank my battleship!" in output)
Ejemplo n.º 9
0
 def test_invalid(self, mock_input):
     output, value = get_function_output(lambda: self.load())
     self.assertTrue("Oops, that's not even in the ocean." in output)
Ejemplo n.º 10
0
 def test_guess_correct(self, mock_input):
     output, value = get_function_output(lambda: self.load())
     self.assertTrue("Congratulations! You sank my battleship!" in output)
 def test(self, mock_input):
     output, value = get_function_output(lambda: self.load())
     expect = ['swimming', 'running', 'football']
     self.assertListEqual(expect, value)
    def test_description(self):
        output, value = get_function_output(lambda: hippo.description())
        expected = f"""{hippo.name}
{hippo.age}
"""
        self.assertEqual(expected, output)