# Path: flatland/schema/scalars.py
# class String(Scalar):
#     """A regular old Unicode string."""
# 
#     strip = True
#     """If true, strip leading and trailing whitespace during conversion."""
# 
#     def adapt(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return None
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     def serialize(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``u'' if *value* is ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return u''
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     @property
#     def is_empty(self):
#         """True if the String is missing or has no value."""
#         return True if (not self.value and self.u == u'') else False
# 
# Path: flatland/out/generic.py
# class Markup(unicode):
#     """A unicode string of HTML markup that should not be escaped in output."""
#     __slots__ = ()
# 
#     # Not a full featured implementation.
# 
#     def __html__(self):
#         return self
# 
# Path: tests/markup/_util.py
# def render_genshi_06(markup, language, schema, wrap=True, **context):
#     if wrap:
#         markup = _wrap_with_xmlns(markup, language)
#     return _render_genshi_06(markup, language, schema, **context)
# 
# def need(capability):
#     def decorator(fn):
#         @wraps(fn)
#         def decorated(*args, **kw):
#             if not have[capability]:
#                 raise SkipTest
#             return fn(*args, **kw)
#         return decorated
#     return decorator


from flatland import String
from flatland.out.generic import Markup
from genshi.template.base import TemplateSyntaxError
from tests._util import assert_raises
from tests.markup._util import render_genshi_06 as render, need
    from flatland.out import genshi_06
"""
    expected = """\
<form name="element">
  <input name="element" value="" />
</form>"""

    rendered = render(markup, 'xhtml', schema)
    assert rendered == expected


def test_attribute_interpolation():
    markup = """\
<input form:bind="form" form:auto-domid="${ON}" />
<input form:bind="form" form:auto-domid="o${N}" />
<input type="checkbox" value="${VAL}" form:bind="form" />
<input type="checkbox" value="v${A}l" form:bind="form" />
<input type="checkbox" value="${V}a${L}" form:bind="form" />
"""
    expected = """\
<input name="element" value="val" id="f_element" />
<input name="element" value="val" id="f_element" />
<input type="checkbox" value="val" name="element" checked="checked" />
<input type="checkbox" value="val" name="element" checked="checked" />
<input type="checkbox" value="val" name="element" checked="checked" />"""

    rendered = render(markup, 'xhtml', schema.from_defaults,
                      ON=u'on',
                      N=u'n',
                      VAL=Markup(u'val'),
                      V=u'v',

# Path: flatland/schema/scalars.py
# class String(Scalar):
#     """A regular old Unicode string."""
# 
#     strip = True
#     """If true, strip leading and trailing whitespace during conversion."""
# 
#     def adapt(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return None
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     def serialize(self, value):
#         """Return a Unicode representation.
# 
#         :returns: a ``unicode`` value or ``u'' if *value* is ``None``
# 
#         If :attr:`strip` is true, leading and trailing whitespace will be
#         removed.
# 
#         """
#         if value is None:
#             return u''
#         elif self.strip:
#             return unicode(value).strip()
#         else:
#             return unicode(value)
# 
#     @property
#     def is_empty(self):
#         """True if the String is missing or has no value."""
#         return True if (not self.value and self.u == u'') else False
# 
# Path: flatland/out/generic.py
# class Markup(unicode):
#     """A unicode string of HTML markup that should not be escaped in output."""
#     __slots__ = ()
# 
#     # Not a full featured implementation.
# 
#     def __html__(self):
#         return self
# 
# Path: tests/markup/_util.py
# def render_genshi_06(markup, language, schema, wrap=True, **context):
#     if wrap:
#         markup = _wrap_with_xmlns(markup, language)
#     return _render_genshi_06(markup, language, schema, **context)
# 
# def need(capability):
#     def decorator(fn):
#         @wraps(fn)
#         def decorated(*args, **kw):
#             if not have[capability]:
#                 raise SkipTest
#             return fn(*args, **kw)
#         return decorated
#     return decorator


# Path: tests/markup/test_genshi_06.py
from flatland import String
from flatland.out.generic import Markup
from genshi.template.base import TemplateSyntaxError
from tests._util import assert_raises
from tests.markup._util import render_genshi_06 as render, need
    from flatland.out import genshi_06

"""
    expected = """\
<form name="element">
  <input name="element" value="" />
</form>"""

    rendered = render(markup, 'xhtml', schema)
    assert rendered == expected


def test_attribute_interpolation():
    markup = """\
<input form:bind="form" form:auto-domid="${ON}" />
<input form:bind="form" form:auto-domid="o${N}" />
<input type="checkbox" value="${VAL}" form:bind="form" />
<input type="checkbox" value="v${A}l" form:bind="form" />
<input type="checkbox" value="${V}a${L}" form:bind="form" />
"""
    expected = """\
<input name="element" value="val" id="f_element" />
<input name="element" value="val" id="f_element" />
<input type="checkbox" value="val" name="element" checked="checked" />
<input type="checkbox" value="val" name="element" checked="checked" />
<input type="checkbox" value="val" name="element" checked="checked" />"""

    rendered = render(markup, 'xhtml', schema.from_defaults,
                      ON=u'on',
                      N=u'n',
                      VAL=Markup(u'val'),
                      V=u'v',

                      A=u'a',