@@ -678,22 +678,20 @@ def test_print_output_format_text_no_result_failure():
678678 assert excinfo .value .status_code == constant .ERROR_INVALID_INPUT
679679
680680
681- @pytest .mark .skipif (
682- platform .system () == "Windows" ,
683- reason = "Failed to run on windows with vscode - no real console" ,
684- )
685- def test_print_entries_key_value_style_success (capsys ):
681+ def test_print_entries_key_value_style_success (mock_questionary_print ):
686682 """Test printing entries in key-value format."""
687683
688684 # Test with single dictionary entry
689685 entry = {"logged_in" : "true" , "account_name" : "johndoe@example.com" }
690686 ui ._print_entries_key_value_list_style (entry )
691687
692- captured = capsys .readouterr ()
693- # print_grey outputs to stderr with to_stderr=False, so check stdout
694- output = captured .out
695- assert "Logged In: true" in output
696- assert "Account Name: johndoe@example.com" in output
688+ # Verify the correct formatted output was printed
689+ assert mock_questionary_print .call_count == 2
690+ printed_calls = [call .args [0 ] for call in mock_questionary_print .call_args_list ]
691+ assert "Logged In: true" in printed_calls
692+ assert "Account Name: johndoe@example.com" in printed_calls
693+
694+ mock_questionary_print .reset_mock ()
697695
698696 # Test with list of dictionaries
699697 entries = [
@@ -702,19 +700,21 @@ def test_print_entries_key_value_style_success(capsys):
702700 ]
703701 ui ._print_entries_key_value_list_style (entries )
704702
705- captured = capsys .readouterr ()
706- output = captured .out
707- assert "User Name: john" in output
708- assert "Status: active" in output
709- assert "User Name: jane" in output
710- assert "Status: inactive" in output
703+ # Verify output for list of entries (should include empty line between entries, but not after last)
704+ assert mock_questionary_print .call_count == 5 # 2 for john + 1 empty line + 2 for jane
705+ printed_calls = [call .args [0 ] for call in mock_questionary_print .call_args_list ]
706+ assert "User Name: john" in printed_calls
707+ assert "Status: active" in printed_calls
708+ assert "User Name: jane" in printed_calls
709+ assert "Status: inactive" in printed_calls
710+ assert "" in printed_calls # Empty line between entries (but not after the last entry)
711+
712+ mock_questionary_print .reset_mock ()
711713
712714 # Test with empty list
713715 ui ._print_entries_key_value_list_style ([])
714- captured = capsys .readouterr ()
715- # Should not output anything for empty list
716- assert captured .err == ""
717- assert captured .out == ""
716+ # Should not call print for empty list
717+ mock_questionary_print .assert_not_called ()
718718
719719
720720def test_print_entries_key_value_style_invalid_input ():
0 commit comments