7013: strip underscores from accept/reject labels
svn: r23077
This commit is contained in:
parent
52d8a77864
commit
ff89425e50
@ -72,16 +72,19 @@ class TestUser_prompt(unittest.TestCase):
|
|||||||
), "False expected!"
|
), "False expected!"
|
||||||
self.user._input.assert_called_once_with()
|
self.user._input.assert_called_once_with()
|
||||||
|
|
||||||
def assert_prompt_contains_text(self, text):
|
def assert_prompt_contains_text(self, text,
|
||||||
|
title=TestUser.TITLE, msg=TestUser.MSG,
|
||||||
|
accept=TestUser.ACCEPT, reject=TestUser.REJECT):
|
||||||
self.user._input.configure_mock(return_value = TestUser.REJECT)
|
self.user._input.configure_mock(return_value = TestUser.REJECT)
|
||||||
self.user.prompt(TestUser.TITLE, TestUser.MSG,
|
self.user.prompt(title, msg, accept, reject)
|
||||||
TestUser.ACCEPT, TestUser.REJECT)
|
|
||||||
for call in self.user._fileout.method_calls:
|
for call in self.user._fileout.method_calls:
|
||||||
name, args, kwargs = call
|
name, args, kwargs = call
|
||||||
for a in args:
|
for a in args:
|
||||||
if a.find(text) >= 0:
|
if a.find(text) >= 0:
|
||||||
return
|
return
|
||||||
assert False,"'{}' never printed in prompt".format(text)
|
self.assertTrue(False,
|
||||||
|
"'{}' never printed in prompt: {}".format(
|
||||||
|
text, self.user._fileout.method_calls))
|
||||||
|
|
||||||
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
||||||
def test_prompt_contains_title_text(self):
|
def test_prompt_contains_title_text(self):
|
||||||
@ -99,6 +102,14 @@ class TestUser_prompt(unittest.TestCase):
|
|||||||
def test_prompt_contains_reject_text(self):
|
def test_prompt_contains_reject_text(self):
|
||||||
self.assert_prompt_contains_text(TestUser.REJECT)
|
self.assert_prompt_contains_text(TestUser.REJECT)
|
||||||
|
|
||||||
|
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
||||||
|
def test_prompt_strips_underscore_in_accept(self):
|
||||||
|
self.assert_prompt_contains_text("accepT", accept="accep_T")
|
||||||
|
|
||||||
|
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
||||||
|
def test_prompt_strips_underscore_in_reject(self):
|
||||||
|
self.assert_prompt_contains_text("reJect", reject="re_Ject")
|
||||||
|
|
||||||
if not MOCKING: #don't use SKIP, to avoid counting a skipped test
|
if not MOCKING: #don't use SKIP, to avoid counting a skipped test
|
||||||
def test_manual_run(self):
|
def test_manual_run(self):
|
||||||
b = self.real_user.prompt(
|
b = self.real_user.prompt(
|
||||||
|
@ -136,6 +136,8 @@ class User(user.User):
|
|||||||
@returns: the user's answer to the question
|
@returns: the user's answer to the question
|
||||||
@rtype: bool
|
@rtype: bool
|
||||||
"""
|
"""
|
||||||
|
accept_label = accept_label.replace("_", "")
|
||||||
|
reject_label = reject_label.replace("_", "")
|
||||||
text = "{t}\n{m} ([{y}]/{n}): ".format(
|
text = "{t}\n{m} ([{y}]/{n}): ".format(
|
||||||
t = title,
|
t = title,
|
||||||
m = message,
|
m = message,
|
||||||
|
Loading…
Reference in New Issue
Block a user