MCPcopy
hub / github.com/django/django / test_aggregate_arity

Method test_aggregate_arity

tests/aggregation/tests.py:2364–2383  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2362 self.assertEqual(list(author_qs), [337])
2363
2364 def test_aggregate_arity(self):
2365 funcs_with_inherited_constructors = [Avg, Max, Min, Sum]
2366 msg = "takes exactly 1 argument (2 given)"
2367 for function in funcs_with_inherited_constructors:
2368 with (
2369 self.subTest(function=function),
2370 self.assertRaisesMessage(TypeError, msg),
2371 ):
2372 function(Value(1), Value(2))
2373
2374 funcs_with_custom_constructors = [Count, StdDev, Variance]
2375 for function in funcs_with_custom_constructors:
2376 with self.subTest(function=function):
2377 # Extra arguments are rejected via the constructor.
2378 with self.assertRaises(TypeError):
2379 function(Value(1), True, Value(2))
2380 # If the constructor is skipped, the arity check runs.
2381 func_instance = function(Value(1), True)
2382 with self.assertRaisesMessage(TypeError, msg):
2383 super(function, func_instance).__init__(Value(1), Value(2))
2384
2385 @skipIfDBFeature("supports_bit_aggregations")
2386 def test_bit_aggregations_not_supported(self):

Callers

nothing calls this directly

Calls 4

ValueClass · 0.90
functionFunction · 0.85
assertRaisesMessageMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected