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
Uh oh!
There was an error while loading. Please reload this page.
-
I've been working on making tests run in async mode, thankfully I found that it's already supported using the
IsolatedAsyncioTestCasebut still it fails in some cases and can't understand why.The failing test is
test_deletehttps://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_asyncisthread_sensitive=Truefor all patchedQuerySetAsyncmethods, unless I'm missing something, this should not be the case.IsolatedAsyncioTestCaseis using different loops ?The source code if
unittestsshows that it's the same loop for all tests. : https://github.com/python/cpython/blob/main/Lib/unittest/async_case.py#L159async_createis not persisting the object ? :No because django doc says that
createis equivalient to instanciating object and.save()No,
id(TestModel.objects)is the same.Beta Was this translation helpful? Give feedback.
All reactions