File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 11import logging
22from requests import Response , Session
3+ from requests .exceptions import HTTPError
34
45logger = logging .getLogger (__name__ )
56
@@ -71,9 +72,10 @@ def __exit__(self, *args):
7172 if len (args ) > 1 and isinstance (args [1 ], Exception )
7273 else self .commit ()
7374 )
74- assert (
75- 204 == response .status_code
76- ), f"Could not end transaction; cause: { response .text } "
75+ # raise_for_status() is not used here as it results in an error without any
76+ # context of what went wrong.
77+ if response .status_code != 204 :
78+ raise HTTPError (f"Could not end transaction; cause: { response .text } " )
7779
7880
7981class TransactionManager :
Original file line number Diff line number Diff line change 22import time
33from marklogic import Client
44from marklogic .documents import Document
5+ from requests .exceptions import HTTPError
56
67PERMS = {"python-tester" : ["read" , "update" ]}
78
@@ -65,7 +66,7 @@ def test_time_limit(client: Client):
6566 doc1 = Document ("/t1.json" , {}, permissions = PERMS )
6667 client .documents .write (doc1 , tx = tx )
6768
68- except AssertionError as error :
69+ except HTTPError as error :
6970 assert error .args [0 ].startswith ("Could not end transaction" )
7071 assert "No transaction with identifier" in error .args [0 ]
7172 assert "XDMP-NOTXN" in error .args [0 ]
You can’t perform that action at this time.
0 commit comments