def test_if_provider_returns_new_instances_each_time(self): provider = NewInstancesProvider(TestClass1) ret1 = provider.get_instance() ret2 = provider.get_instance() assert isinstance(ret1, TestClass1) assert isinstance(ret2, TestClass1) assert ret1 is not ret2
def test_if_provider_returns_instance(self): provider = NewInstancesProvider(TestClass1) ret1 = provider.get_instance() assert isinstance(ret1, TestClass1)
def test_if_provider_raise_error_when_initialized_with_not_callable(self): with pytest.raises(TypeError): NewInstancesProvider(1)
def test_if_provider_raise_error_when_callable_requires_arguments(self): def func1(a): return a with pytest.raises(TypeError): NewInstancesProvider(func1)