@@ -578,14 +578,14 @@ def test_duration_in_words(duration_in_seconds, words):
578578
579579
580580@pytest .mark .parametrize (
581- "transaction_status ,expected" ,
581+ "is_failed,is_valid ,expected" ,
582582 [
583- ("*" , "*testuser" ),
584- ("!" , "!testuser" ),
585- ("" , "testuser" ),
583+ (False , True , "*testuser" ), # valid transaction → "*"
584+ (True , False , "!testuser" ), # failed transaction → "!"
585+ (False , False , "testuser" ), # idle → ""
586586 ],
587587)
588- def test_get_prompt_with_transaction_status (transaction_status , expected ):
588+ def test_get_prompt_with_transaction_status (is_failed , is_valid , expected ):
589589 """Test that \\ x prompt variable shows transaction status."""
590590 cli = PGCli ()
591591 cli .pgexecute = mock .MagicMock ()
@@ -597,10 +597,10 @@ def test_get_prompt_with_transaction_status(transaction_status, expected):
597597 cli .pgexecute .pid = 12345
598598 cli .pgexecute .superuser = False
599599
600- with mock . patch . object (
601- cli .pgexecute , "transaction_status" , return_value = transaction_status
602- ):
603- result = cli .get_prompt ("\\ x\\ u" )
600+ cli . pgexecute . failed_transaction . return_value = is_failed
601+ cli .pgexecute . valid_transaction . return_value = is_valid
602+
603+ result = cli .get_prompt ("\\ x\\ u" )
604604 assert result == expected
605605
606606
@@ -616,10 +616,10 @@ def test_get_prompt_transaction_status_in_full_prompt():
616616 cli .pgexecute .pid = 12345
617617 cli .pgexecute .superuser = False
618618
619- with mock . patch . object (
620- cli .pgexecute , "transaction_status" , return_value = "*"
621- ):
622- result = cli .get_prompt ("\\ x\\ u@\\ h:\\ d> " )
619+ cli . pgexecute . failed_transaction . return_value = False
620+ cli .pgexecute . valid_transaction . return_value = True
621+
622+ result = cli .get_prompt ("\\ x\\ u@\\ h:\\ d> " )
623623 assert result == "*user@db.example.com:mydb> "
624624
625625
0 commit comments