Skip to content

Commit c0b125a

Browse files
committed
review fixes
1 parent 6f980fe commit c0b125a

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

tests/query/test_query_session_pool.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ def callee(session: QuerySessionSync):
3939
assert len(res) == 1
4040

4141
def test_retry_op_raises(self, pool: QuerySessionPool):
42+
class CustomException(Exception):
43+
pass
44+
4245
def callee(session: QuerySessionSync):
43-
with session.execute("Caught in a landslide, no escape from reality"):
44-
pass
46+
raise CustomException()
4547

46-
with pytest.raises(ydb.GenericError):
48+
with pytest.raises(CustomException):
4749
pool.retry_operation_sync(callee)

tests/query/test_query_transaction.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ def test_tx_allow_double_rollback(self, tx: BaseTxContext):
2121
tx.rollback()
2222
tx.rollback()
2323

24-
@pytest.mark.skip(reason="Not sure should we keep this behavior or not")
25-
def test_tx_commit_raises_before_begin(self, tx: BaseTxContext):
26-
with pytest.raises(RuntimeError):
27-
tx.commit()
24+
def test_tx_commit_before_begin(self, tx: BaseTxContext):
25+
tx.commit()
26+
assert tx._tx_state._state == QueryTxStateEnum.COMMITTED
2827

29-
@pytest.mark.skip(reason="Not sure should we keep this behavior or not")
30-
def test_tx_rollback_raises_before_begin(self, tx: BaseTxContext):
31-
with pytest.raises(RuntimeError):
32-
tx.rollback()
28+
def test_tx_rollback_before_begin(self, tx: BaseTxContext):
29+
tx.rollback()
30+
assert tx._tx_state._state == QueryTxStateEnum.ROLLBACKED
3331

3432
def test_tx_first_execute_begins_tx(self, tx: BaseTxContext):
3533
tx.execute("select 1;")
@@ -67,9 +65,12 @@ def test_context_manager_normal_flow(self, tx: BaseTxContext):
6765
assert tx._tx_state._state == QueryTxStateEnum.COMMITTED
6866

6967
def test_context_manager_does_not_hide_exceptions(self, tx: BaseTxContext):
70-
with pytest.raises(Exception):
68+
class CustomException(Exception):
69+
pass
70+
71+
with pytest.raises(CustomException):
7172
with tx:
72-
raise Exception()
73+
raise CustomException()
7374

7475
def test_execute_as_context_manager(self, tx: BaseTxContext):
7576
tx.begin()

ydb/query/transaction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ def commit(self, settings=None):
253253
self._ensure_prev_stream_finished()
254254

255255
if self._tx_state._state == QueryTxStateEnum.NOT_INITIALIZED:
256-
# TODO(vgvoleg): Discuss should we raise before begin or not
257256
self._tx_state._change_state(QueryTxStateEnum.COMMITTED)
258257
self._tx_state.tx_id = None
259258
return
@@ -276,7 +275,6 @@ def rollback(self, settings=None):
276275
self._ensure_prev_stream_finished()
277276

278277
if self._tx_state._state == QueryTxStateEnum.NOT_INITIALIZED:
279-
# TODO(vgvoleg): Discuss should we raise before begin or not
280278
self._tx_state._change_state(QueryTxStateEnum.ROLLBACKED)
281279
self._tx_state.tx_id = None
282280
return

0 commit comments

Comments
 (0)