Replies: 3 comments 2 replies
-
any ideas @allen-munsch ? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm a bit confused now, becaue even in sync orm I have the same issue class SyncTestCase(TestCase):
def test_delete(self):
created = TestModel.objects.create(name='sync to delete')
all_created = TestModel.objects.all()
print(all_created) output
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Well, the whole issue was about that I was using |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been working on making tests run in async mode, thankfully I found that it's already supported using the
IsolatedAsyncioTestCase
but still it fails in some cases and can't understand why.The failing test is
test_delete
https://github.com/rednaks/django-async-orm/blob/main/tests/test_django_async_orm.py#L111I create an object, and then delete everything.
but before deleting I wanted to test if the object really exists in the database. so get retrieve all objects :
TestModel.objects.async_all()
but here where things get weird, the list is empty ..
I tried to understand why, here is what I investigated:
No
sync_to_async
isthread_sensitive=True
for all patchedQuerySetAsync
methods, unless I'm missing something, this should not be the case.IsolatedAsyncioTestCase
is using different loops ?The source code if
unittests
shows that it's the same loop for all tests. : https://github.com/python/cpython/blob/main/Lib/unittest/async_case.py#L159async_create
is not persisting the object ? :No because django doc says that
create
is equivalient to instanciating object and.save()
No,
id(TestModel.objects)
is the same.Beta Was this translation helpful? Give feedback.
All reactions