MCPcopy
hub / github.com/django/django / test_query_representation

Method test_query_representation

tests/raw_query/tests.py:260–284  ·  view source on GitHub ↗

Test representation of raw query with parameters

(self)

Source from the content-addressed store, hash-verified

258 self.assertIsInstance(repr(qset), str)
259
260 def test_query_representation(self):
261 """
262 Test representation of raw query with parameters
263 """
264 query = "SELECT * FROM raw_query_author WHERE last_name = %(last)s"
265 qset = Author.objects.raw(query, {"last": "foo"})
266 self.assertEqual(
267 repr(qset),
268 "<RawQuerySet: SELECT * FROM raw_query_author WHERE last_name = foo>",
269 )
270 self.assertEqual(
271 repr(qset.query),
272 "<RawQuery: SELECT * FROM raw_query_author WHERE last_name = foo>",
273 )
274
275 query = "SELECT * FROM raw_query_author WHERE last_name = %s"
276 qset = Author.objects.raw(query, {"foo"})
277 self.assertEqual(
278 repr(qset),
279 "<RawQuerySet: SELECT * FROM raw_query_author WHERE last_name = foo>",
280 )
281 self.assertEqual(
282 repr(qset.query),
283 "<RawQuery: SELECT * FROM raw_query_author WHERE last_name = foo>",
284 )
285
286 def test_many_to_many(self):
287 """

Callers

nothing calls this directly

Calls 1

rawMethod · 0.45

Tested by

no test coverage detected