예제 #1
0
    def testProcessIgnoresCrossScopeHierarchyReferenceIfNotStrict(self):

        container = ContainerBuilder();
        container.addScope(Scope('a'));
        container.addScope(Scope('b'));

        container.register('a').setScope('a').addArgument(Reference('b', ContainerInterface.EXCEPTION_ON_INVALID_REFERENCE, False));
        container.register('b').setScope('b');

        self._process(container);
예제 #2
0
    def testProcessIgnoresCrossScopeHierarchyReferenceIfNotStrict(self):

        container = ContainerBuilder()
        container.addScope(Scope('a'))
        container.addScope(Scope('b'))

        container.register('a').setScope('a').addArgument(
            Reference('b', ContainerInterface.EXCEPTION_ON_INVALID_REFERENCE,
                      False))
        container.register('b').setScope('b')

        self._process(container)
예제 #3
0
    def testProcessDetectsCrossScopeHierarchyReference(self):
        """@expectedException RuntimeException

        """
        try:

            container = ContainerBuilder();
            container.addScope(Scope('a'));
            container.addScope(Scope('b'));
    
            container.register('a').setScope('a').addArgument(Reference('b'));
            container.register('b').setScope('b');
    
            self._process(container);
        
            self.fail()
        except Exception as e:
            self.assertTrue(isinstance(e, RuntimeException));
예제 #4
0
    def testProcessDetectsCrossScopeHierarchyReference(self):
        """@expectedException RuntimeException

        """
        try:

            container = ContainerBuilder()
            container.addScope(Scope('a'))
            container.addScope(Scope('b'))

            container.register('a').setScope('a').addArgument(Reference('b'))
            container.register('b').setScope('b')

            self._process(container)

            self.fail()
        except Exception as e:
            self.assertTrue(isinstance(e, RuntimeException))