1717try :
1818 import msvcrt
1919except ImportError :
20- mscvrt = None
20+ msvcrt = None
2121
2222@mock .patch ('os.environ' )
2323class GetpassGetuserTest (unittest .TestCase ):
@@ -185,16 +185,11 @@ def test_uses_msvcrt_directly(self):
185185 mock_stream .flush .assert_called ()
186186
187187 def test_handles_backspace (self ):
188- with (
189- mock .patch ('msvcrt.getch' ) as getch ,
190- mock .patch ('msvcrt.putch' ) as putch ,
191- ):
188+ with mock .patch ('msvcrt.getch' ) as getch , \
189+ mock .patch ('msvcrt.putch' ) as putch :
192190 getch .side_effect = [b'a' , b'b' , b'\b ' , b'c' , b'\r ' ]
193191 result = getpass .win_getpass ()
194192 self .assertEqual (result , 'ac' )
195- # Verify putch was called to handle the backspace (erase character)
196- # The exact sequence depends on the implementation, but should include
197- # calls to handle the backspace character
198193 putch .assert_any_call (b'\b ' )
199194
200195 def test_handles_ctrl_c (self ):
@@ -214,8 +209,7 @@ def test_flushes_stream_after_input(self):
214209
215210 def test_falls_back_to_fallback_if_msvcrt_raises (self ):
216211 with mock .patch ('msvcrt.getch' ) as getch , \
217- mock .patch ('getpass.fallback_getpass' ) as fallback :
218- # Make getch raise an exception to trigger the fallback
212+ mock .patch ('getpass.fallback_getpass' ) as fallback :
219213 getch .side_effect = RuntimeError ("Simulated msvcrt failure" )
220214 mock_stream = mock .Mock (spec = StringIO )
221215 getpass .win_getpass (stream = mock_stream )
0 commit comments