| 12345678910111213141516171819202122232425262728293031323334353637383940 | import asyncioimport osfrom pydantic import HttpUrlfrom clean_python import ctxfrom clean_python import Tenantfrom clean_python import Userdef test_default_context():    assert str(ctx.path) == "file://" + os.getcwd()    assert ctx.user.id == "ANONYMOUS"    assert ctx.user.name == "anonymous"    assert ctx.tenant is Noneasync def test_task_isolation():    async def get_set(user):        ctx.user = user        asyncio.sleep(0.01)        assert ctx.user == user    await asyncio.gather(*[get_set(User(id=str(i), name="piet")) for i in range(10)])    assert ctx.user.id == "ANONYMOUS"async def test_tenant():    tenant = Tenant(id=2, name="foo")    ctx.tenant = tenant    assert ctx.tenant == tenant    ctx.tenant = None    assert ctx.tenant is Noneasync def test_path():    url = HttpUrl("http://testserver/foo?a=b")    ctx.path = url    assert ctx.path == url
 |