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

Function test_push_interrupted_from_callbacks

test/test_remote.py:451–483  ·  view source on GitHub ↗
(
    origin: Repository, clone: Repository, remote: Remote, reject_from: str
)

Source from the content-addressed store, hash-verified

449
450@pytest.mark.parametrize('reject_from', ['push_transfer_progress', 'push_negotiation'])
451def test_push_interrupted_from_callbacks(
452 origin: Repository, clone: Repository, remote: Remote, reject_from: str
453) -> None:
454 reject_message = 'retreat! retreat!'
455
456 tip = clone[clone.head.target]
457 clone.create_commit(
458 'refs/heads/master',
459 tip.author,
460 tip.author,
461 'empty commit',
462 tip.tree.id,
463 [tip.id],
464 )
465
466 class MyCallbacks(pygit2.RemoteCallbacks):
467 def push_negotiation(self, updates: list[PushUpdate]) -> None:
468 if reject_from == 'push_negotiation':
469 raise InterruptedError(reject_message)
470
471 def push_transfer_progress(
472 self, objects_pushed: int, total_objects: int, bytes_pushed: int
473 ) -> None:
474 if reject_from == 'push_transfer_progress':
475 raise InterruptedError(reject_message)
476
477 assert origin.branches['master'].target == tip.id
478
479 callbacks = MyCallbacks()
480 with pytest.raises(InterruptedError, match='retreat! retreat!'):
481 remote.push(['refs/heads/master'], callbacks=callbacks)
482
483 assert origin.branches['master'].target == tip.id
484
485
486def test_push_non_fast_forward_commits_to_remote_fails(

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
MyCallbacksClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…