def test_askpass(self, mock_getpass: Mock): def getpass(prompt, stream): stream.write(prompt) return "hello" output = StringIO() console = ConsoleOutput(output) mock_getpass.side_effect = getpass self.assertEqual("hello", console.askpass("test: ")) self.assertEqual("test: ", output.getvalue())
def test_askpass(self, isatty, getpass): isatty.return_value = True getpass.return_value = "hello" self.assertEqual("hello", ConsoleOutput.askpass("test: "))
def test_askpass_no_tty(self, isatty): isatty.return_value = False self.assertEqual("", ConsoleOutput.askpass("test: "))
def test_askpass_no_tty(self): output = StringIO() console = ConsoleOutput(output) self.assertIsNone(console.askpass("test: "))