diff --git a/src/twisted/conch/scripts/ckeygen.py b/src/twisted/conch/scripts/ckeygen.py index 6e2fe4c5311..525d585a257 100644 --- a/src/twisted/conch/scripts/ckeygen.py +++ b/src/twisted/conch/scripts/ckeygen.py @@ -208,9 +208,9 @@ def getKeyOrDefault(options): filename = os.path.expanduser("~/.ssh/id_rsa") if platform.system() == "Windows": filename = os.path.expandvars(R"%HOMEPATH %\.ssh\id_rsa") - options["filename"] = input( - "Enter file in which the key is (%s): " % filename - ) or filename + options["filename"] = ( + input("Enter file in which the key is (%s): " % filename) or filename + ) def printFingerprint(options): diff --git a/src/twisted/conch/test/test_ckeygen.py b/src/twisted/conch/test/test_ckeygen.py index 35e40fc0dd1..22545073e40 100644 --- a/src/twisted/conch/test/test_ckeygen.py +++ b/src/twisted/conch/test/test_ckeygen.py @@ -635,9 +635,12 @@ def test_useDefaultForKey(self): L{options} will default to "~/.ssh/id_rsa" if the user doesn't specify a key. """ + def mock_input(*args): return "" + import builtins + self.patch(builtins, "input", mock_input) options = {"filename": ""} getKeyOrDefault(options) @@ -669,4 +672,3 @@ def test_handleBadFilePrintFingerprint(self): options = {"filename": "/foo/bar", "format": "md5-hex"} with self.assertRaises(SystemExit): printFingerprint(options) -