Browse Source

Merge branch 'master' into tinnet/master

main
Lakshmi Vyasarajan 14 years ago
parent
commit
f24219bfb9
3 changed files with 31 additions and 1 deletions
  1. +1
    -1
      hyde/ext/plugins/auto_extend.py
  2. +10
    -0
      hyde/model.py
  3. +20
    -0
      hyde/tests/test_model.py

+ 1
- 1
hyde/ext/plugins/auto_extend.py View File

@@ -21,7 +21,7 @@ class AutoExtendPlugin(Plugin):
an extends statement to the top of the file.
"""

if not resource.is_processable or not resource.uses_template:
if not resource.uses_template:
return text
layout = None
block = None


+ 10
- 0
hyde/model.py View File

@@ -57,6 +57,16 @@ class Expando(object):
else:
return primitive

def to_dict(self):
"""
Reverse transform an expando to dict
"""
d = self.__dict__
for k, v in d.iteritems():
if isinstance(v, Expando):
d[k] = v.to_dict()
return d


class Context(object):
"""


+ 20
- 0
hyde/tests/test_model.py View File

@@ -43,6 +43,26 @@ def test_expando_update():
assert x.a == 789
assert x.f == "opq"

def test_expando_to_dict():
d = {"a": 123, "b": {"c": 456, "d": {"e": "abc"}}}
x = Expando(d)
assert d == x.to_dict()

def test_expando_to_dict_with_update():
d1 = {"a": 123, "b": "abc"}
x = Expando(d1)
d = {"b": {"c": 456, "d": {"e": "abc"}}, "f": "lmn"}
x.update(d)
expected = {}
expected.update(d1)
expected.update(d)
assert expected == x.to_dict()
d2 = {"a": 789, "f": "opq"}
y = Expando(d2)
x.update(y)
expected.update(d2)
assert expected == x.to_dict()

TEST_SITE = File(__file__).parent.child_folder('_test')

import yaml


Loading…
Cancel
Save