Skip to content

Commit

Permalink
Remove sync wrapped call inside .get (#191)
Browse files Browse the repository at this point in the history
jacobtomlinson authored Oct 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 223cbe8 commit ac350dc
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kr8s/_objects.py
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ async def get(
if cls._asyncio:
api = await kr8s.asyncio.api()
else:
api = kr8s.api()
api = await kr8s.asyncio.api(_asyncio=False)
namespace = namespace if namespace else api.namespace
start = time.time()
backoff = 0.1
15 changes: 15 additions & 0 deletions kr8s/tests/test_objects.py
Original file line number Diff line number Diff line change
@@ -223,6 +223,21 @@ async def test_pod_get(example_pod_spec):
await pod2.delete()


def test_pod_get_sync(example_pod_spec):
pod = SyncPod(example_pod_spec)
pod.create()
with pytest.raises(kr8s.NotFoundError):
SyncPod.get(f"{pod.name}-foo", namespace=pod.namespace, timeout=0.1)
pod2 = SyncPod.get(pod.name, namespace=pod.namespace)
assert pod2.name == pod.name
assert pod2.namespace == pod.namespace
pod.delete()
while pod.exists():
time.sleep(0.1)
with pytest.raises(kr8s.NotFoundError):
pod2.delete()


async def test_pod_from_name(example_pod_spec):
pod = await Pod(example_pod_spec)
await pod.create()

0 comments on commit ac350dc

Please sign in to comment.