import pytest

from flagon.utils import ConfigDict
import copy
import traceback

def test_config():
    c = ConfigDict()
    c.debug = True
    assert c.debug == True
    assert c['debug'] == True

    c['app'] = ConfigDict({'a': 1, 'b': 'foo'})
    assert c.app.a == 1
    assert c.app.b == 'foo'
    assert 'app' in c

    del c.app
    assert 'app' not in c


def test_cached_property():
    pass

@@ -43,16 +43,33 @@
 nfigDict
+, cached_property
 %0Aimport 
@@ -206,16 +206,95 @@
  == True
+%0A    c.debug = False%0A    assert c.debug == False%0A    assert c%5B'debug'%5D == False
 %0A%0A    c%5B
@@ -454,43 +454,350 @@
 n c%0A
-%0A%0Adef test_cached_property():%0A    pass
+    with pytest.raises(AttributeError):%0A        app = c.app%0A        del c.app%0A%0A%0Adef test_cached_property():%0A    class Foo(object):%0A        def __init__(self):%0A            self.num = 1%0A%0A        @cached_property%0A        def foo(self):%0A            self.num += 1%0A            return self.num%0A%0A    f = Foo()%0A    assert f.foo == 2%0A    assert f.foo == 2
 %0A

add more tescase in testutils