Download testbed/django__django/tests/async/test_async_model_methods.py from hc99/FEA-Bench: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/django__django/tests/async/test_async_model_methods.py
- Command line
-
hf download hf://datasets/hc99/FEA-Bench/testbed/django__django/tests/async/test_async_model_methods.py
-
curl -L -o test_async_model_methods.py https://huggingface.co/datasets/hc99/FEA-Bench/resolve/main/testbed/django__django/tests/async/test_async_model_methods.py
752 Bytes
| from django.test import TestCase | |
| from .models import SimpleModel | |
| class AsyncModelOperationTest(TestCase): | |
| def setUpTestData(cls): | |
| cls.s1 = SimpleModel.objects.create(field=0) | |
| async def test_asave(self): | |
| self.s1.field = 10 | |
| await self.s1.asave() | |
| refetched = await SimpleModel.objects.aget() | |
| self.assertEqual(refetched.field, 10) | |
| async def test_adelete(self): | |
| await self.s1.adelete() | |
| count = await SimpleModel.objects.acount() | |
| self.assertEqual(count, 0) | |
| async def test_arefresh_from_db(self): | |
| await SimpleModel.objects.filter(pk=self.s1.pk).aupdate(field=20) | |
| await self.s1.arefresh_from_db() | |
| self.assertEqual(self.s1.field, 20) | |