Beispiel #1
0
 def test_prompt_validate(self, stdin):
     """ Prompt user until return value passes validation check """
     invals = ['foo', 'bar']
     stdin.side_effect = lambda x: invals.pop(0)
     ret = scripts.prompt('', validate=lambda x: x == 'bar')
     self.assertEqual(ret, 'bar')
Beispiel #2
0
 def test_prompt_default(self, stdin):
     """ If user hits 'enter', return default value """
     stdin.return_value = ''
     ret = scripts.prompt('', default='abc')
     self.assertEqual(ret, 'abc')
Beispiel #3
0
 def test_prompt_no_default(self, stdin):
     """ If no default, require a value """
     invals = ['', 'foo']
     stdin.side_effect = lambda x: invals.pop(0)
     ret = scripts.prompt('')
     self.assertEqual(ret, 'foo')
Beispiel #4
0
 def test_prompt_validate(self, stdin):
     """ Prompt user until return value passes validation check """
     invals = ["foo", "bar"]
     stdin.side_effect = lambda x: invals.pop(0)
     ret = scripts.prompt("", validate=lambda x: x == "bar")
     self.assertEqual(ret, "bar")
Beispiel #5
0
 def test_prompt_default(self, _):
     """ If user hits 'enter', return default value """
     ret = scripts.prompt("", default="abc")
     self.assertEqual(ret, "abc")
Beispiel #6
0
 def test_prompt_validate(self, stdin):
     """ Prompt user until return value passes validation check """
     invals = ['foo', 'bar']
     stdin.side_effect = lambda x: invals.pop(0)
     ret = scripts.prompt('', validate=lambda x: x == 'bar')
     self.assertEqual(ret, 'bar')
Beispiel #7
0
 def test_prompt_no_default(self, stdin):
     """ If no default, require a value """
     invals = ['', 'foo']
     stdin.side_effect = lambda x: invals.pop(0)
     ret = scripts.prompt('')
     self.assertEqual(ret, 'foo')
Beispiel #8
0
 def test_prompt_default(self, stdin):
     """ If user hits 'enter', return default value """
     stdin.return_value = ''
     ret = scripts.prompt('', default='abc')
     self.assertEqual(ret, 'abc')