markwalker,
@markwalker@fosstodon.org avatar

Is there a way to count the number of queries in tests if you're using django's regular built in testcase?

I'm too used to pytest these days 🤔

emattiza,
@emattiza@hachyderm.io avatar

@markwalker You can import CaptureQueriesContext from django.test.utils (assertNumQueries uses this indirectly). Give it a grep on the django github repo and youll find some tests which show a bit how to use it over a connection import.

markwalker,
@markwalker@fosstodon.org avatar

@emattiza Oo nice, I haven't actually ever dug into how assertNumQueries operates, so that makes sense!

Thanks, I'll take a look 👍

CodenameTim,
@CodenameTim@fosstodon.org avatar
CodenameTim,
@CodenameTim@fosstodon.org avatar

@markwalker Oh no, that looks like it might be limited to only TransactionTestCase

  • All
  • Subscribed
  • Moderated
  • Favorites
  • django
  • kavyap
  • thenastyranch
  • ethstaker
  • DreamBathrooms
  • osvaldo12
  • magazineikmin
  • tacticalgear
  • Youngstown
  • everett
  • mdbf
  • slotface
  • ngwrru68w68
  • rosin
  • Durango
  • JUstTest
  • InstantRegret
  • GTA5RPClips
  • tester
  • cubers
  • cisconetworking
  • normalnudes
  • khanakhh
  • modclub
  • anitta
  • Leos
  • megavids
  • provamag3
  • lostlight
  • All magazines