From c2b61defb3ce37f7764e854a4916791fd858bd02 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Thu, 6 Apr 2017 10:58:07 +0300 Subject: [PATCH] Add performance test for overridden providers --- tests/performance/test.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/performance/test.py b/tests/performance/test.py index 59464a9c..b157dc42 100644 --- a/tests/performance/test.py +++ b/tests/performance/test.py @@ -74,7 +74,7 @@ class Tester(object): # for x in xrange(int(5000000 * self.duration_factor)): # test_factory(1, 2, 3) - def test_instance_3_kw_injections(self, providers): + def test_raw_3_kw_injections(self, providers): """Test 3 keyword argument injections.""" class A(object): pass @@ -92,7 +92,7 @@ class Tester(object): for x in xrange(int(5000000 * self.duration_factor)): Test(a=A(), b=B(), c=C()) - def test_instance_factory_3_factory_kw_injections(self, providers): + def test_factory_3_factory_kw_injections(self, providers): """Test factory with 3 keyword argument injections via factories.""" class A(object): pass @@ -117,6 +117,32 @@ class Tester(object): for x in xrange(int(5000000 * self.duration_factor)): test_factory() + def test_overridden_factory_3_factory_kw_injections(self, providers): + """Test factory with 3 keyword argument injections via factories.""" + class A(object): + pass + + class B(object): + pass + + class C(object): + pass + + class Test(object): + def __init__(self, a, b, c): + pass + + a_factory = providers.Factory(A) + b_factory = providers.Factory(B) + c_factory = providers.Factory(C) + test_factory = providers.Factory(object) + test_factory.override(providers.Factory(Test, + a=a_factory, + b=b_factory, + c=c_factory)) + for x in xrange(int(5000000 * self.duration_factor)): + test_factory() + # def test_factory_subcls_3_factory_subcls_kw_injections(self, providers): # """Test factory with 3 keyword argument injections via factories.""" # class MyFactory(providers.Factory):