Exemplo n.º 1
0
 def tearDown(self):
     # After each test, scope should be reset to root
     expected, found = '', be._get_scope()
     # Sanitize global scope for the next test in case something went wrong
     be._reset()
     self.assertEqual(
         expected, found,
         'Variable scope was not properly closed in the last test. ')
Exemplo n.º 2
0
 def tearDown(self):
     # After each test, scope should be reset to root
     expected, found = '', be._get_scope()
     # Sanitize global scope for the next test in case something went wrong
     be._reset()
     self.assertEqual(
         expected, found,
         'Variable scope was not properly closed in the last test. ')
Exemplo n.º 3
0
 def test_VariableScope_correctly_closes_scope(self):
     """VariableScope revert current variable scope after close"""
     scopes = [self.get_scope(scope) for scope in ['aaa', 'bbb', 'ccc']]
     for scope in scopes:
         expected_scope = be._get_scope()
         expected_reuse = be._get_flag()
         with nn.VariableScope(False, scope):
             pass
         self._check_scope(expected_scope)
         self._check_reuse(expected_reuse)
Exemplo n.º 4
0
 def test_VariableScope_correctly_closes_scope(self):
     """VariableScope revert current variable scope after close"""
     scopes = [self.get_scope(scope) for scope in ['aaa', 'bbb', 'ccc']]
     for scope in scopes:
         expected_scope = be._get_scope()
         expected_reuse = be._get_flag()
         with nn.VariableScope(False, scope):
             pass
         self._check_scope(expected_scope)
         self._check_reuse(expected_reuse)
Exemplo n.º 5
0
 def _check_scope(self, expected, found=None):
     found = found or be._get_scope()
     self.assertEqual(expected, found,
                      'Failed to update current variable scope. ')
Exemplo n.º 6
0
 def _check_scope(self, expected, found=None):
     found = found or be._get_scope()
     self.assertEqual(
         expected, found,
         'Failed to update current variable scope. '
     )