mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-23 05:56:19 +03:00
Add the test
This commit is contained in:
parent
16fbb37694
commit
aa3317c7eb
|
@ -1,5 +1,6 @@
|
||||||
"""Dependency injector base providers unit tests."""
|
"""Dependency injector base providers unit tests."""
|
||||||
|
|
||||||
|
from abc import ABC
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
from dependency_injector import (
|
from dependency_injector import (
|
||||||
|
@ -249,6 +250,19 @@ class DependencyTests(unittest.TestCase):
|
||||||
def test_init_with_not_class(self):
|
def test_init_with_not_class(self):
|
||||||
self.assertRaises(TypeError, providers.Dependency, object())
|
self.assertRaises(TypeError, providers.Dependency, object())
|
||||||
|
|
||||||
|
def test_with_abc(self):
|
||||||
|
class Base(ABC):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Implementation(Base):
|
||||||
|
pass
|
||||||
|
|
||||||
|
provider = providers.Dependency(Base)
|
||||||
|
provider.provided_by(providers.Object(Implementation()))
|
||||||
|
|
||||||
|
self.assertIsInstance(provider(), Base)
|
||||||
|
self.assertIsInstance(provider(), Implementation)
|
||||||
|
|
||||||
def test_is_provider(self):
|
def test_is_provider(self):
|
||||||
self.assertTrue(providers.is_provider(self.provider))
|
self.assertTrue(providers.is_provider(self.provider))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user