Exemple #1
0
    def test_confirm_asks_again_for_invalid_input(self):
        """Test that confirm ask again if the input is invalid"""
        returns = ["invalid input", "yes"]
        side_effect = lambda x: returns.pop(0)

        with mock.patch("__builtin__.raw_input", side_effect=side_effect):
            utils.confirm("test string", False)
Exemple #2
0
 def test_confirm(self):
     """Test confirm with an ascii string"""
     with mock.patch("__builtin__.raw_input", return_value="yes"):
         utils.confirm("test string", False)
Exemple #3
0
 def test_confirm_result_matches_answer(self):
     """Test that the result returned by confirm matches the answer given"""
     with mock.patch("__builtin__.raw_input", return_value="yes"):
         assert utils.confirm("prompt", False) is True
     with mock.patch("__builtin__.raw_input", return_value="no"):
         assert utils.confirm("prompt", False) is False
Exemple #4
0
 def test_confirm_unicode(self):
     """Test confirm with a unicode string"""
     with mock.patch("__builtin__.raw_input", return_value="yes"):
         utils.confirm(u"test string with unicode: \u2007", False)