def test_correct_digits(self): code = [1, 2, 3, 4] with captured_io(StringIO("4321\n1423\n3214\n2134\n1234")): self.assertEqual(mastermind.take_turn(code), (0, 4)) self.assertEqual(mastermind.take_turn(code), (1, 3)) self.assertEqual(mastermind.take_turn(code), (2, 2)) self.assertEqual(mastermind.take_turn(code), (2, 2)) self.assertEqual(mastermind.take_turn(code), (4, 0))
def test_take_turn(self): """ Checks if the 'correct_digits_and_position' and the 'correct_digits_only' is correct """ self.assertEqual(mastermind.take_turn([6, 4, 2, 5], [5, 4, 2, 6]), (2, 2)) self.assertEqual(mastermind.take_turn([5, 6, 2, 3], [5, 3, 1, 6]), (1, 2)) self.assertEqual(mastermind.take_turn([6, 5, 4, 3], [6, 5, 4, 3]), (4, 0))
def test_take_turn(self): """ this method test take_turn() function """ test = mastermind.take_turn([1, 2, 3, 4]) self.assertEqual(test, (4, 0)) test = mastermind.take_turn([4, 3, 2, 1]) self.assertEqual(test, (0, 4)) test = mastermind.take_turn([5, 2, 3, 4]) self.assertEqual(test, (3, 0)) test = mastermind.take_turn([8, 7, 6, 5]) self.assertEqual(test, (0, 0)) test = mastermind.take_turn([1, 3, 2, 4]) self.assertEqual(test, (2, 2))
def test_take_turns(self): output = StringIO() sys.stdout = output sys.stdout = sys.__stdout__ answer = ["1","2","3","4"] code = [1,2,3,4] result = mastermind.take_turn(answer,code) compare_tuple = (4,0) self.assertEqual(result,compare_tuple)
def test_take_turn(self): code = [1, 2, 3, 4] out = StringIO() with redirect_stdout(out): #with captured_io(StringIO("5678\n8765\n5687")): attempt = mastermind.take_turn(code, "1234") self.assertEqual((attempt[0], attempt[1]), (4, 0)) attempt = mastermind.take_turn(code,"4321") self.assertEqual((attempt[0], attempt[1]), (0, 4)) attempt = mastermind.take_turn(code,"1243") self.assertEqual((attempt[0], attempt[1]), (2, 2)) attempt = mastermind.take_turn(code,"1423") self.assertEqual((attempt[0], attempt[1]), (1, 3)) # if __name__ == "__main__": # unittest.main()
def test_take_turn(self): self.assertEqual(mastermind.take_turn([1, 2, 3, 4]), (4, 0)) self.assertEqual(mastermind.take_turn([1, 2, 3, 7]), (3, 0)) self.assertEqual(mastermind.take_turn([1, 3, 4, 5]), (1, 2))
def test_take_turn(self): """tests whether the function take_turn return a right tuple""" code = [1, 2, 3, 4] self.assertIsInstance(mastermind.take_turn(code), tuple)
def test_take_turn(self): self.assertEqual(mastermind.take_turn([1,2,3,4], "4321"), (0, 4)) self.assertEqual(mastermind.take_turn([1,2,3,4], "1234"), (4, 0)) self.assertEqual(mastermind.take_turn([1,2,3,4], "1267"), (2, 0)) self.assertEqual(mastermind.take_turn([1,2,3,4], "1243"), (2, 2))
def test_take_turn(self): self.assertEqual(take_turn([2, 3, 4, 5], [2, 3, 4, 5]), (4, 0)) self.assertEqual(take_turn([2, 3, 4, 5], [6, 2, 8, 3]), (0, 2)) self.assertEqual(take_turn([2, 3, 4, 5], [1, 3, 6, 5]), (2, 0))