Skip to content

Commit 17a5891

Browse files
committed
Add update tests
1 parent c608b7a commit 17a5891

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Lib/test/test_getpass.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,23 @@ def test_echochar_replaces_input_with_asterisks(self):
168168
mock.patch('io.TextIOWrapper') as textio, \
169169
mock.patch('termios.tcgetattr'), \
170170
mock.patch('termios.tcsetattr'), \
171-
mock.patch('getpass._input_with_echochar') as mock_input:
171+
mock.patch('getpass._raw_input') as mock_input:
172172
os_open.return_value = 3
173173
mock_input.return_value = mock_result
174174

175175
result = getpass.unix_getpass(echochar='*')
176-
mock_input.assert_called_once_with('Password: ', textio(), textio(), '*')
176+
mock_input.assert_called_once_with('Password: ', textio(),
177+
input=textio(), echochar='*')
177178
self.assertEqual(result, mock_result)
178179

179-
def test_input_with_echochar(self):
180+
def test_raw_input_with_echochar(self):
180181
passwd = 'my1pa$$word!'
181182
mock_input = StringIO(f'{passwd}\n')
182183
mock_output = StringIO()
183184
with mock.patch('sys.stdin', mock_input), \
184185
mock.patch('sys.stdout', mock_output):
185-
result = getpass._input_with_echochar('Password: ', mock_output,
186-
mock_input, '*')
186+
result = getpass._raw_input('Password: ', mock_output, mock_input,
187+
'*')
187188
self.assertEqual(result, passwd)
188189
self.assertEqual('Password: ************', mock_output.getvalue())
189190

@@ -194,8 +195,8 @@ def test_control_chars_with_echochar(self):
194195
mock_output = StringIO()
195196
with mock.patch('sys.stdin', mock_input), \
196197
mock.patch('sys.stdout', mock_output):
197-
result = getpass._input_with_echochar('Password: ', mock_output,
198-
mock_input, '*')
198+
result = getpass._raw_input('Password: ', mock_output, mock_input,
199+
'*')
199200
self.assertEqual(result, expect_result)
200201
self.assertEqual('Password: *******\x08 \x08', mock_output.getvalue())
201202

0 commit comments

Comments
 (0)