2013-08-27 21:36:52 +02:00
|
|
|
# coding: utf-8
|
|
|
|
import autopath
|
|
|
|
#from py.test import raises
|
|
|
|
|
|
|
|
from tiramisu.config import Config
|
|
|
|
from tiramisu.option import BoolOption, OptionDescription
|
|
|
|
import weakref
|
|
|
|
|
|
|
|
|
|
|
|
def test_deref_storage():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(c.cfgimpl_get_values()._p_)
|
|
|
|
del(c)
|
|
|
|
assert w() is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_deref_value():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(c.cfgimpl_get_values())
|
|
|
|
del(c)
|
|
|
|
assert w() is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_deref_setting():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(c.cfgimpl_get_settings())
|
|
|
|
del(c)
|
|
|
|
assert w() is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_deref_config():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(c)
|
|
|
|
del(c)
|
|
|
|
assert w() is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_deref_option():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
w = weakref.ref(b)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME
|
|
|
|
#assert w() is None
|
2013-08-27 21:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_deref_optiondescription():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
w = weakref.ref(o)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME
|
|
|
|
#assert w() is None
|
2013-08-27 21:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_deref_option_cache():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
o.impl_build_cache()
|
|
|
|
w = weakref.ref(b)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME l'objet n'est plus en mémoire mais par contre reste dans la base
|
|
|
|
#Voir comment supprimer (et quand)
|
|
|
|
#assert w() is None
|
2013-08-27 21:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_deref_optiondescription_cache():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
o.impl_build_cache()
|
|
|
|
w = weakref.ref(o)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME
|
|
|
|
#assert w() is None
|
2013-08-27 21:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_deref_option_config():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(b)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
|
|
|
assert w() is not None
|
|
|
|
del(c)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME meme chose
|
|
|
|
#assert w() is None
|
2013-08-27 21:36:52 +02:00
|
|
|
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME rien a voir mais si je fais un config.impl_get_path_by_opt() ca me retourne la methode !
|
2013-08-27 21:36:52 +02:00
|
|
|
def test_deref_optiondescription_config():
|
|
|
|
b = BoolOption('b', '')
|
|
|
|
o = OptionDescription('od', '', [b])
|
|
|
|
c = Config(o)
|
|
|
|
w = weakref.ref(o)
|
|
|
|
del(b)
|
|
|
|
assert w() is not None
|
|
|
|
del(o)
|
|
|
|
assert w() is not None
|
|
|
|
del(c)
|
2013-11-23 23:34:17 +01:00
|
|
|
#FIXME
|
|
|
|
#assert w() is None
|