diff --git a/gramps/cli/test/user_test.py b/gramps/cli/test/user_test.py index e1da67426..e8bc1f025 100644 --- a/gramps/cli/test/user_test.py +++ b/gramps/cli/test/user_test.py @@ -23,7 +23,6 @@ import unittest from .. import user -from ...gen.test.user_test import TestUser import sys try: @@ -38,6 +37,12 @@ except: MOCKING = False print ("Mocking disabled", sys.exc_info()[0:2]) +class TestUser: + TITLE = "Testing prompt" + MSG = "Choices are hard. Nevertheless, please choose!" + ACCEPT = "To be" + REJECT = "Not to be" + class TestUser_prompt(unittest.TestCase): def setUp(self): self.real_user = user.User() diff --git a/gramps/cli/user.py b/gramps/cli/user.py index 355e58713..503e27ef6 100644 --- a/gramps/cli/user.py +++ b/gramps/cli/user.py @@ -152,7 +152,7 @@ class User(user.User): reply = "" ### Trun response into True/False: if reply == "": - return default + return default == accept_label elif reply == accept_label: return True else: diff --git a/gramps/gui/test/user_test.py b/gramps/gui/test/user_test.py index 6d6794612..0e90b6c69 100644 --- a/gramps/gui/test/user_test.py +++ b/gramps/gui/test/user_test.py @@ -23,7 +23,6 @@ import unittest from .. import user -from ...gen.test.user_test import TestUser import sys try: @@ -38,6 +37,12 @@ except: MOCKING = False print ("Mocking disabled", sys.exc_info()[0:2]) +class TestUser: + TITLE = "Testing prompt" + MSG = "Choices are hard. Nevertheless, please choose!" + ACCEPT = "To be" + REJECT = "Not to be" + class TestUser_prompt(unittest.TestCase): def setUp(self): self.user = user.User() @@ -46,9 +51,10 @@ class TestUser_prompt(unittest.TestCase): def test_prompt_runs_QuestionDialog2(self): with patch('gramps.gui.user.QuestionDialog2') as MockQD: self.user.prompt(TestUser.TITLE, TestUser.MSG, - TestUser.ACCEPT, TestUser.REJECT, None) + TestUser.ACCEPT, TestUser.REJECT, parent=None) MockQD.assert_called_once_with(TestUser.TITLE, TestUser.MSG, - TestUser.ACCEPT, TestUser.REJECT, None) + TestUser.ACCEPT, TestUser.REJECT, + parent=None) MockQD.return_value.run.assert_called_once_with() # TODO test that run's return is the one returned by prompt()...