From 7da8eb1fdb755b2ebd618337f318be56bed3b0e6 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 9 Jun 2015 11:37:33 -0400 Subject: [PATCH] Delay constructing the set of mongo calls until they're needed --- .../lib/xmodule/xmodule/modulestore/tests/factories.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index 9e1f1ae5c7..e27be9f0ab 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -330,18 +330,18 @@ def check_sum_of_calls(object_, methods, maximum_calls, minimum_calls=1): yield call_count = sum(mock.call_count for mock in mocks.values()) - calls = pprint.pformat({ - method_name: mock.call_args_list - for method_name, mock in mocks.items() - }) # Assertion errors don't handle multi-line values, so pretty-print to std-out instead if not minimum_calls <= call_count <= maximum_calls: + calls = { + method_name: mock.call_args_list + for method_name, mock in mocks.items() + } print "Expected between {} and {} calls, {} were made. Calls: {}".format( minimum_calls, maximum_calls, call_count, - calls, + pprint.pformat(calls), ) # verify the counter actually worked by ensuring we have counted greater than (or equal to) the minimum calls