예제 #1
0
    def test_history_toolbar(self):
        human = Human()
        expected_content = ""
        actual_content = human._history_toolbar()
        self.assertEqual(actual_content, expected_content)

        human.history.append(C, C)
        expected_content = "History (human, opponent): [('C', 'C')]"
        actual_content = human._history_toolbar()
        self.assertIn(actual_content, expected_content)
예제 #2
0
    def test_history_toolbar(self):
        human = Human()
        expected_content = ""
        actual_content = human._history_toolbar()
        self.assertEqual(actual_content, expected_content)

        human.history = [C]
        human.opponent_history = [C]
        expected_content = "History (human, opponent): [('C', 'C')]"
        actual_content = human._history_toolbar()
        self.assertIn(actual_content, expected_content)
예제 #3
0
    def test_repr(self):
        human = Human()
        self.assertEqual(human.__repr__(), "Human: human")

        human = Human(name="John Nash")
        self.assertEqual(human.__repr__(), "Human: John Nash")
        human = Human(name="John Nash", c_symbol="1", d_symbol="2")
        self.assertEqual(human.__repr__(), "Human: John Nash")
예제 #4
0
    def test_history_toolbar(self):
        human = Human()
        expected_content = ''
        actual_content = human._history_toolbar(None)[0][1]
        self.assertEqual(actual_content, expected_content)

        human.history = ['C']
        human.opponent_history = ['C']
        # We can't test for this expected content properly until we drop
        # support for Python 2 as the strings within a string aren't handled
        # properly.
        expected_content = "History (Human, opponent): [('C', 'C')]"
        actual_content = human._history_toolbar(None)[0][1]
        self.assertIn('History (Human, opponent)', actual_content)
예제 #5
0
    def test_status_messages(self):
        human = Human()
        expected_messages = {
            "toolbar": None,
            "print": "{}Starting new match".format(linesep),
        }
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages, expected_messages)

        human.history.append(C, C)
        expected_print_message = "{}Turn 1: human played C, opponent played C".format(
            linesep)
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages["print"], expected_print_message)
        self.assertIsNotNone(actual_messages["toolbar"])
예제 #6
0
    def test_status_messages(self):
        human = Human()
        expected_messages = {
            'toolbar': None,
            'print': '{}Starting new match'.format(linesep)
        }
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages, expected_messages)

        human.history = ['C']
        human.opponent_history = ['C']
        expected_print_message = (
            '{}Turn 1: Human played C, opponent played C'.format(linesep)
        )
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages['print'], expected_print_message)
        self.assertIsNotNone(actual_messages['toolbar'])
예제 #7
0
    def test_status_messages(self):
        human = Human()
        expected_messages = {
            "toolbar": None,
            "print": "{}Starting new match".format(linesep),
        }
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages, expected_messages)

        human.history = [C]
        human.opponent_history = [C]
        expected_print_message = "{}Turn 1: human played C, opponent played C".format(
            linesep
        )
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages["print"], expected_print_message)
        self.assertIsNotNone(actual_messages["toolbar"])
예제 #8
0
    def test_repr(self):
        human = Human()
        self.assertEqual(human.__repr__(), "Human: human")

        human = Human(name="John Nash")
        self.assertEqual(human.__repr__(), "Human: John Nash")
        human = Human(name="John Nash", c_symbol="1", d_symbol="2")
        self.assertEqual(human.__repr__(), "Human: John Nash")
예제 #9
0
    def test_history_toolbar(self):
        human = Human()
        expected_content = ''
        actual_content = human._history_toolbar(None)[0][1]
        self.assertEqual(actual_content, expected_content)

        human.history = [C]
        human.opponent_history = [C]
        expected_content = "History (Human, opponent): [('C', 'C')]"
        actual_content = human._history_toolbar(None)[0][1]
        self.assertIn(actual_content, expected_content)
예제 #10
0
    def test_history_toolbar(self):
        human = Human()
        expected_content = ''
        actual_content = human._history_toolbar(None)[0][1]
        self.assertEqual(actual_content, expected_content)

        human.history = ['C']
        human.opponent_history = ['C']
        # We can't test for this expected content properly until we drop
        # support for Python 2 as the strings within a string aren't handled
        # properly.
        expected_content = "History (Human, opponent): [('C', 'C')]"
        actual_content = human._history_toolbar(None)[0][1]
        self.assertIn('History (Human, opponent)', actual_content)
예제 #11
0
    def test_status_messages(self):
        human = Human()
        expected_messages = {
            'toolbar': None,
            'print': '{}Starting new match'.format(linesep)
        }
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages, expected_messages)

        human.history = [C]
        human.opponent_history = [C]
        expected_print_message = (
            '{}Turn 1: Human played C, opponent played C'.format(linesep))
        actual_messages = human._status_messages()
        self.assertEqual(actual_messages['print'], expected_print_message)
        self.assertIsNotNone(actual_messages['toolbar'])
예제 #12
0
 def test_strategy(self):
     human = Human()
     expected_action = C
     actual_action = human.strategy(Player(), lambda: C)
     self.assertEqual(actual_action, expected_action)
예제 #13
0
 def test_init(self):
     human = Human(name='test human', c_symbol='X', d_symbol='Y')
     self.assertEqual(human.name, 'test human')
     self.assertEqual(human.symbols, {C: 'X', D: 'Y'})
예제 #14
0
 def test_init(self):
     human = Human(name="test human", c_symbol="X", d_symbol="Y")
     self.assertEqual(human.human_name, "test human")
     self.assertEqual(human.symbols, {C: "X", D: "Y"})
예제 #15
0
 def test_strategy(self):
     human = Human()
     expected_action = 'C'
     actual_action = human.strategy(Player(), lambda: 'C')
     self.assertEqual(actual_action, expected_action)