Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python3 by replacing raw_input with input #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action_plugins/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _prompt(self, result, msg):
m['postfix']
)

var = raw_input(askstr)
var = input(askstr)

if var != "":
if 'confirm' in m and var.lower() not in "yn":
Expand Down
34 changes: 17 additions & 17 deletions test/test_ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_prompt_setInput_default_valid(self):
'/dev/tty'
)

with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': 'varname'
Expand All @@ -134,7 +134,7 @@ def test_prompt_setInput_stringio_valid(self):
self.assertEquals(instr, self.prompt._instr)
self.assertEquals(instr.getvalue(), "")

with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': 'varname'
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_prompt_ask_var_simple_valid(self):
.. versionadded:: 0.2.0
.. function:: test_prompt_ask_var_simple_valid()
"""
with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': 'varname'
Expand All @@ -277,7 +277,7 @@ def test_prompt_ask_var_numbers_valid(self):
.. versionadded:: 0.2.0
.. function:: test_prompt_ask_var_numbers_valid()
"""
with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': '12345'
Expand All @@ -293,7 +293,7 @@ def test_prompt_ask_var_unicode_valid(self):
.. versionadded:: 0.2.0
.. function:: test_prompt_ask_var_unicode_valid()
"""
with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': u'varname'
Expand All @@ -309,7 +309,7 @@ def test_prompt_ask_var_underscore_valid(self):
.. versionadded:: 0.2.0
.. function:: test_prompt_ask_var_underscore_valid()
"""
with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'say': 'test',
'ask': 'var_name'
Expand All @@ -325,7 +325,7 @@ def test_prompt_ask_say_missing_valid(self):
.. versionadded:: 0.2.0
.. function:: test_prompt_ask_say_missing_valid()
"""
with mock.patch('__builtin__.raw_input', return_value='mocked input') as mockinput:
with mock.patch('__builtin__.input', return_value='mocked input') as mockinput:
result = self.prompt._prompt({}, {
'ask': 'varname'
})
Expand Down Expand Up @@ -490,7 +490,7 @@ def return_helper(*args, **kwargs):

return ""

with mock.patch('__builtin__.raw_input', side_effect=return_helper) as mockinput:
with mock.patch('__builtin__.input', side_effect=return_helper) as mockinput:
result = self.prompt._prompt({}, {
'ask': 'varname'
})
Expand All @@ -506,7 +506,7 @@ def test_prompt_msg_shows_default(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_shows_default()
"""
with mock.patch('__builtin__.raw_input', return_value="Andrew") as mockinput:
with mock.patch('__builtin__.input', return_value="Andrew") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "First Name",
"ask": "first_name",
Expand All @@ -527,7 +527,7 @@ def test_prompt_msg_defaults(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_defaults()
"""
with mock.patch('__builtin__.raw_input', return_value="") as mockinput:
with mock.patch('__builtin__.input', return_value="") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "First Name",
"ask": "first_name",
Expand All @@ -547,7 +547,7 @@ def test_prompt_msg_postfix_custom(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_postfix_custom()
"""
with mock.patch('__builtin__.raw_input', return_value="") as mockinput:
with mock.patch('__builtin__.input', return_value="") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "First Name",
"ask": "first_name",
Expand All @@ -568,7 +568,7 @@ def test_prompt_msg_trim_default(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_trim_default()
"""
with mock.patch('__builtin__.raw_input', return_value=" trim value ") as mockinput:
with mock.patch('__builtin__.input', return_value=" trim value ") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "First Name",
"ask": "first_name",
Expand All @@ -584,7 +584,7 @@ def test_prompt_msg_trim_off_valid(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_trim_off_valid()
"""
with mock.patch('__builtin__.raw_input', return_value=" trim value ") as mockinput:
with mock.patch('__builtin__.input', return_value=" trim value ") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "First Name",
"ask": "first_name",
Expand Down Expand Up @@ -616,7 +616,7 @@ def return_helper(*args, **kwargs):

return "foobar"

with mock.patch('__builtin__.raw_input', side_effect=return_helper) as mockinput:
with mock.patch('__builtin__.input', side_effect=return_helper) as mockinput:
result = self.prompt._prompt(self.response, {
"say": "Continue",
"ask": "result",
Expand All @@ -637,7 +637,7 @@ def test_prompt_msg_confirm_blank_default_yes(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_confirm_blank_default_yes()
"""
with mock.patch('__builtin__.raw_input', return_value="") as mockinput:
with mock.patch('__builtin__.input', return_value="") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "Continue",
"ask": "result",
Expand All @@ -657,7 +657,7 @@ def test_prompt_msg_confirm_blank_default_no(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_confirm_blank_default_no()
"""
with mock.patch('__builtin__.raw_input', return_value="") as mockinput:
with mock.patch('__builtin__.input', return_value="") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "Continue",
"ask": "result",
Expand All @@ -677,7 +677,7 @@ def test_prompt_msg_confirm_capital_valid(self):
.. versionadded:: 1.0.0
.. function:: test_prompt_msg_confirm_capital_valid()
"""
with mock.patch('__builtin__.raw_input', return_value="Y") as mockinput:
with mock.patch('__builtin__.input', return_value="Y") as mockinput:
result = self.prompt._prompt(self.response, {
"say": "Continue",
"ask": "result",
Expand Down