MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_transaction_context_manager

Function test_transaction_context_manager

test/test_transaction.py:34–48  ·  view source on GitHub ↗

Test basic transaction with context manager.

(testrepo: Repository)

Source from the content-addressed store, hash-verified

32
33
34def test_transaction_context_manager(testrepo: Repository) -> None:
35 """Test basic transaction with context manager."""
36 master_ref = testrepo.lookup_reference('refs/heads/master')
37 assert str(master_ref.target) == '2be5719152d4f82c7302b1c0932d8e5f0a4a0e98'
38
39 # Create a transaction and update a ref
40 new_target = Oid(hex='5ebeeebb320790caf276b9fc8b24546d63316533')
41
42 with testrepo.transaction() as txn:
43 txn.lock_ref('refs/heads/master')
44 txn.set_target('refs/heads/master', new_target, message='Test update')
45
46 # Verify the update was applied
47 master_ref = testrepo.lookup_reference('refs/heads/master')
48 assert master_ref.target == new_target
49
50
51def test_transaction_rollback_on_exception(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 3

transactionMethod · 0.80
lock_refMethod · 0.80
set_targetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…