Пример #1
0
    def test_nesting(self):
        scope = access.Scope(None)
        scope.mark_write('foo')
        scope.mark_read('bar')

        child = access.Scope(scope)
        self.assertTrue(child.has('foo'))
        self.assertTrue(scope.has('foo'))

        child.mark_write('bar')
        self.assertTrue(child.has('bar'))
        self.assertFalse(scope.has('bar'))
Пример #2
0
    def test_referenced(self):
        scope = access.Scope(None)
        scope.mark_read('a')

        child = access.Scope(scope)
        child.mark_read('b')

        child2 = access.Scope(child, isolated=False)
        child2.mark_read('c')

        self.assertTrue('c' in child2.referenced)
        self.assertTrue('b' in child2.referenced)
        self.assertFalse('a' in child2.referenced)

        self.assertTrue('c' in child.referenced)
        self.assertTrue('b' in child.referenced)
        self.assertFalse('a' in child.referenced)
Пример #3
0
    def test_copy(self):
        scope = access.Scope(None)
        scope.mark_write('foo')

        other = access.Scope(None)
        other.copy_from(scope)

        self.assertTrue('foo' in other.created)

        scope.mark_write('bar')
        scope.copy_from(other)

        self.assertFalse('bar' in scope.created)

        scope.mark_write('bar')
        scope.merge_from(other)

        self.assertTrue('bar' in scope.created)
        self.assertFalse('bar' in other.created)
Пример #4
0
    def test_basic(self):
        scope = access.Scope(None)
        self.assertFalse(scope.has('foo'))

        scope.mark_read('foo')
        self.assertFalse(scope.has('foo'))

        scope.mark_write('foo')
        self.assertTrue(scope.has('foo'))

        scope.mark_read('bar')
        self.assertFalse(scope.has('bar'))