user's input should not be interpreted
using python's "input" rather than "raw_input" raise exception since the user's input is interpreted. In python 3.x raw_input = input, so the interpertation bug only exists in python 2.x Change-Id: I28781a8742d6e03bc850fd0178f317474603a9d2
This commit is contained in:
parent
a65c799a9e
commit
4b63891dd7
@ -19,6 +19,7 @@ import codecs
|
||||
import fnmatch
|
||||
import locale
|
||||
import os.path
|
||||
from six.moves import input
|
||||
|
||||
|
||||
def wrap_stream(stream, encoding='utf-8'):
|
||||
|
@ -17,8 +17,6 @@
|
||||
# of actions by the JJB library, usually through interaction with the
|
||||
# python-jenkins library.
|
||||
|
||||
import six
|
||||
|
||||
from tests.base import mock
|
||||
from tests.cmd.test_cmd import CmdTestsBase
|
||||
|
||||
@ -27,8 +25,6 @@ from tests.cmd.test_cmd import CmdTestsBase
|
||||
mock.MagicMock)
|
||||
class DeleteAllTests(CmdTestsBase):
|
||||
|
||||
input_module = "jenkins_jobs.utils" if six.PY2 else "builtins"
|
||||
|
||||
@mock.patch('jenkins_jobs.cli.subcommand.update.'
|
||||
'JenkinsManager.delete_all_jobs')
|
||||
def test_delete_all_accept(self, delete_job_mock):
|
||||
@ -37,7 +33,7 @@ class DeleteAllTests(CmdTestsBase):
|
||||
"""
|
||||
|
||||
args = ['--conf', self.default_config_file, 'delete-all']
|
||||
with mock.patch('%s.input' % self.input_module, return_value="y"):
|
||||
with mock.patch('jenkins_jobs.utils.input', return_value="y"):
|
||||
self.execute_jenkins_jobs_with_args(args)
|
||||
|
||||
@mock.patch('jenkins_jobs.cli.subcommand.update.'
|
||||
@ -48,6 +44,6 @@ class DeleteAllTests(CmdTestsBase):
|
||||
"""
|
||||
|
||||
args = ['--conf', self.default_config_file, 'delete-all']
|
||||
with mock.patch('%s.input' % self.input_module, return_value="n"):
|
||||
with mock.patch('jenkins_jobs.utils.input', return_value="n"):
|
||||
self.assertRaises(SystemExit,
|
||||
self.execute_jenkins_jobs_with_args, args)
|
||||
|
Loading…
Reference in New Issue
Block a user