Matt Brockman 1a8fed012c
fix: Improve sandbox.git async/sync parity (#1110)
Fixes issue with missing `restore` and `reset` functionality on the
async git sandboxes.
 
Consolidate shared git helpers by moving remote URL argument
construction and
parsing into the git utilities package. Sync and async git modules now
reuse
the same builders where possible, with tests to ensure no drift.

---------

Co-authored-by: Filip Brebera <filip@bxxf.dev>
2026-02-03 11:58:16 -08:00

34 lines
997 B
Python

import inspect
from e2b.sandbox_async.git import Git as AsyncGit
from e2b.sandbox_sync.git import Git as SyncGit
def _public_methods(cls):
return {
name: getattr(cls, name)
for name in sorted(dir(cls))
if not name.startswith("_") and callable(getattr(cls, name))
}
def test_identical_method_signatures():
sync = _public_methods(SyncGit)
async_ = _public_methods(AsyncGit)
assert set(sync) == set(async_), (
f"missing from async: {set(sync) - set(async_)}, "
f"missing from sync: {set(async_) - set(sync)}"
)
for name in sync:
assert inspect.signature(sync[name]) == inspect.signature(async_[name]), (
f"{name}: sync{inspect.signature(sync[name])} "
f"!= async{inspect.signature(async_[name])}"
)
def test_async_methods_are_coroutines():
for name, method in _public_methods(AsyncGit).items():
assert inspect.iscoroutinefunction(method), f"AsyncGit.{name} is not async"