From b1f6963fbefe727a7546b3e3fa39277126358ac4 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Mon, 16 Mar 2015 11:49:34 +0200 Subject: [PATCH] Little tests refactoring --- tests/test_providers.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_providers.py b/tests/test_providers.py index 4675e570..1f7c7219 100644 --- a/tests/test_providers.py +++ b/tests/test_providers.py @@ -300,6 +300,10 @@ class ScopedTests(unittest.TestCase): """Set test cases environment up.""" self.provider = Scoped(object) + def test_is_provider(self): + """Test `is_provider` check.""" + self.assertTrue(is_provider(self.provider)) + def test_call(self): """Test creation and returning of scope single object.""" self.provider.in_scope(self.APPLICATION_SCOPE) @@ -377,26 +381,27 @@ class ExternalDependencyTests(unittest.TestCase): """ExternalDependency test cases.""" + def setUp(self): + """Set test cases environment up.""" + self.provider = ExternalDependency(instance_of=list) + def test_is_provider(self): """Test `is_provider` check.""" - self.assertTrue(is_provider(ExternalDependency(instance_of=object))) + self.assertTrue(is_provider(self.provider)) def test_call_satisfied(self): """Test call of satisfied external dependency.""" - provider = ExternalDependency(instance_of=object) - provider.satisfy(NewInstance(object)) - self.assertIsInstance(provider(), object) + self.provider.satisfy(NewInstance(list)) + self.assertIsInstance(self.provider(), list) def test_call_satisfied_but_not_instance_of(self): """Test call of satisfied external dependency, but not instance of.""" - provider = ExternalDependency(instance_of=list) - provider.satisfy(NewInstance(dict)) - self.assertRaises(Error, provider) + self.provider.satisfy(NewInstance(dict)) + self.assertRaises(Error, self.provider) def test_call_not_satisfied(self): """Test call of not satisfied external dependency.""" - provider = ExternalDependency(instance_of=object) - self.assertRaises(Error, provider) + self.assertRaises(Error, self.provider) class StaticProvidersTests(unittest.TestCase):