Example #1
0
    def test_check_correctness(self):
        """  this method test check_correctness() function """
        correct = mastermind.check_correctness(4, 1)
        self.assertTrue(correct)

        correct = mastermind.check_correctness(3, 12)
        self.assertFalse(correct)
Example #2
0
 def test_check_correctness(self):
     """Tests tht the check_correctness function checks the correctness of the players input and returns the appropriate boolean """
     with patch("sys.stdout", new=StringIO()) as fakeout:
         mastermind.check_correctness(11, 4)
     self.assertEqual(fakeout.getvalue(),
                      "Congratulations! You are a codebreaker!\n")
     with patch("sys.stdout", new=StringIO()) as fakeout:
         mastermind.check_correctness(11, 0)
     self.assertEqual(fakeout.getvalue(), "Turns left: 0\n")
    def test_check_correctness(self):
        """
        Checks if the user for the code right. If its wrong the user has 12 turns, if its right it
        displays 'Congratulations! You are a codebreaker!'
        """

        sys.stdout = io.StringIO()
        self.assertTrue(mastermind.check_correctness(6, 4))
        self.assertEqual(sys.stdout.getvalue(),
                         'Congratulations! You are a codebreaker!\n')

        sys.stdout = io.StringIO()
        self.assertFalse(mastermind.check_correctness(5, 3))
        self.assertEqual(sys.stdout.getvalue(), 'Turns left: 7\n')
    def test_show_results(self):
        #output = StringIO()

        #sys.stdout = output

        #sys.stdout = sys.__stdout__

        result = True
        self.assertEqual(mastermind.check_correctness(8, 4), result)
Example #5
0
 def test_correctness(self):
     result = mastermind.check_correctness(4, 1)
     self.assertTrue(result)
 def test_check_correctness(self):
     self.assertEqual(mastermind.check_correctness(11, 4), True)
     self.assertEqual(mastermind.check_correctness(12, 4), True)
 def test_check_correction(self):
     with captured_io(''):
         self.assertEqual(mastermind.check_correctness(1, 4, True), True)
Example #8
0
 def test_check_correctness(self):
     out = StringIO()
     with redirect_stdout(out):
         self.assertEqual(mastermind.check_correctness(4, 0), True)
         self.assertEqual(mastermind.check_correctness(5, 3), False)
Example #9
0
 def test_check_correctness(self):
     """tests whether check_correctness checks correctness of answer 
     and show output to user"""
     self.assertEqual(check_correctness(8, 1), False)
     self.assertEqual(check_correctness(0, 4), True)
 def test_check_correctness(self):
     self.assertTrue(mastermind.check_correctness(0,4))
     self.assertFalse(mastermind.check_correctness(0,3))
     self.assertFalse(mastermind.check_correctness(0,2))
     self.assertFalse(mastermind.check_correctness(0,1))
     self.assertFalse(mastermind.check_correctness(0,0))
Example #11
0
 def test_correctness(self):
     output = StringIO()
     sys.stdout = output
     self.assertEqual(mastermind.check_correctness(4,5),True)
     self.assertEqual(mastermind.check_correctness(5,7),False)
     sys.stdout = sys.__stdout__
Example #12
0
    def test_check_correctness(self):

        self.assertEqual(check_correctness(12, True, 4), True)
        self.assertEqual(check_correctness(12, False, 1), False)