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)
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)
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")
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)
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"])
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'])
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"])
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)
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'])
def test_strategy(self): human = Human() expected_action = C actual_action = human.strategy(Player(), lambda: C) self.assertEqual(actual_action, expected_action)
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'})
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"})
def test_strategy(self): human = Human() expected_action = 'C' actual_action = human.strategy(Player(), lambda: 'C') self.assertEqual(actual_action, expected_action)