Ejemplo n.º 1
0
 def test_module_reference_valid_after_reload(self):
     from avalon.test import material01a
     from avalon.test import material01b
     v = material01b.f()
     builtin.reload(material01a)
     self.assertTrue (v != material01a.value,
                      'Material01a is designed to provide a different value each time it is reloaded, '
                      'which is not satisfied.')
     self.assertTrue ((material01a.value == material01b.f()) 
                      and (material01b._DEPENDENCY_[0] == material01a)
                      and (id(material01b._DEPENDENCY_[0]) == id(material01a)),
                      'If there are two modules that one uses another, the master cannot correctly get '
                      'control of the slave module after it is reloaded, which feature is required by '
                      'Avalon framework.')
     self.assertTrue ((material01b._DEPENDENCY_[0] == material01b._DEPENDENCY_[1])
                      and (material01b.f() == material01b.f2()),
                      'Though the object id of reloaded module is same as the original one, you cannot '
                      'use `import Module as Alias` Or `from Module import Module`, which is required by '
                      'Avalon framework.')
Ejemplo n.º 2
0
 def test_reload_module(self):
     '''
     Test module dependency managed reload.
     
     Codes samples are the same as unittest01.
     '''
     from avalon.test import material01a
     from avalon.test import material01b
     builtin.reload(material01a)
     self.assertTrue (material01a.value != material01b.value_cache,
                      'Material01b will not be automatically reloaded when '
                      'material01a is reloading.')
     v = material01a.value
     module.reload_dir(os.path.dirname(material01b.__file__), [material01b])
     self.assertTrue (v != material01a.value,
                      'Material01a should be managed reloaded while material01b '
                      'is reloading.')
     self.assertTrue (material01a.value == material01b.value_cache,
                      'Material01a should be reloaded before material01b, '
                      'thus material01b.value_cache should just be material01a.value.')