Hi,
On Oct/10/2020, Peter Inglesby wrote:
I remember reading the original thread...
> I've authored PR 12417 <
https://github.com/django/django/pull/12417> (Fixed
> 31235 <
https://code.djangoproject.com/ticket/31235> -- Updated
> assertQuerysetEqual to compare querysets directly) which has added a new
> RemovedInDjango41Warning... which causes hundreds of test failures.
>
> Unfortunately I have no spare time at the moment to resolve these. Would
> anybody on this list like to take the PR off my hands?
I was now reading the updated documentation and code. Just to help
someone to fix the unit tests, is this what you thought that should be
done?
----------
diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py
index 2ac2f8cc84..f265339c4f 100644
--- a/tests/transactions/tests.py
+++ b/tests/transactions/tests.py
@@ -163,12 +163,12 @@ class AtomicTests(TransactionTestCase):
def test_reuse_commit_rollback(self):
atomic = transaction.atomic()
with atomic:
- Reporter.objects.create(first_name="Tintin")
+ reporter = Reporter.objects.create(first_name="Tintin")
with self.assertRaisesMessage(Exception, "Oops"):
with atomic:
Reporter.objects.create(first_name="Haddock")
raise Exception("Oops, that's his last name")
- self.assertQuerysetEqual(Reporter.objects.all(), ['<Reporter: Tintin>'])
+ self.assertQuerysetEqual(Reporter.objects.all(), [reporter])
def test_reuse_rollback_commit(self):
atomic = transaction.atomic()
----------
(and another 257... with my DB setup)
It does fix the unit test, I don't know if this is what you intended.
Or, a smaller fix:
self.assertQuerysetEqual(Reporter.objects.all(), ['Tintin'], transform=str)
Which at least doesn't require thinking of a variable name (and it might
be easier if the objects are not created by the surrounding code, I
haven't checked if this happens often or not).
Or, did I take the wrong side of the stick and you intended the fix to be
different?
Have a good weekend,
--
Carles Pina i Estany
https://carles.pina.cat