def check_copy_constructor(self): """Regression test against a bug introduced in 0.3.7 The TestContext copy constructor was copying the ServiceRegistry object by reference. As a result, services registering themselves with one test context would be registered with the copied context as well, resulting in the length of the service registry to grow additively from test to test. This problem cropped up in particular with parametrized tests. """ expander = MarkedFunctionExpander(session_context=session_context(), cls=DummyTest, function=DummyTest.test_me) ctx_list = expander.expand() for ctx in ctx_list: # Constructing an instance of the test class causes a service to be registered with the test context ctx.cls(ctx) # Ensure that each context.services object is a unique reference assert len(set(id(ctx.services) for ctx in ctx_list)) == len(ctx_list)
def expand_function(self, t_ctx): expander = MarkedFunctionExpander(t_ctx.session_context, t_ctx.module, t_ctx.cls, t_ctx.function) return expander.expand(self.test_parameters)