Files
packages/lang/python/python-asgiref/test.sh
T
Wei-Ting Yang 5a36a775df python-asgiref: improve version check in test.sh
Verify that asgiref.__version__ strictly equals the expected version
argument ($2), instead of just checking that it is non-empty.

Also remove single quotes from EOF to enable variable expansion.

Signed-off-by: Wei-Ting Yang <williamatcg@gmail.com>
(cherry picked from commit bdab2f1f59)
2026-07-16 08:51:08 +02:00

25 lines
541 B
Bash
Executable File

#!/bin/sh
[ "$1" = python3-asgiref ] || exit 0
python3 - << EOF
import asgiref
assert asgiref.__version__ == "$2", "Incorrect asgiref version"
from asgiref.sync import async_to_sync, sync_to_async
import asyncio
async def async_add(a, b):
return a + b
result = async_to_sync(async_add)(3, 4)
assert result == 7, f"async_to_sync failed: {result}"
def sync_mul(a, b):
return a * b
async def run():
result = await sync_to_async(sync_mul)(6, 7)
assert result == 42, f"sync_to_async failed: {result}"
asyncio.run(run())
EOF