# 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/markup.py
# class Generator(Context):
# 
#     def __init__(self, markup='xhtml', **options):
#         Context.__init__(self)
#         if markup == 'html':
#             self.xml = False
#         elif markup in ('xhtml', 'xml'):
#             self.xml = True
#         else:
#             raise TypeError("Unknown markup type %r" % markup)
#         self._tags = defaultdict(list)
#         self._frames[-1].update(_default_options)
#         self.push()
#         self.update(options)
# 
#     def begin(self, **settings):
#         self.push(**settings)
#         return self['markup_wrapper'](u'')
# 
#     def end(self):
#         if len(self._frames) == 2:
#             raise RuntimeError("end() without matching begin()")
#         self.pop()
#         return self['markup_wrapper'](u'')
# 
#     def set(self, **settings):
#         for key, value in settings.items():
#             if key not in self:
#                 raise TypeError(
#                     "%r is not a valid argument." % key)
#             if key.startswith('auto_'):
#                 value = parse_trool(value)
#             self[key] = value
#         return self['markup_wrapper'](u'')
# 
#     @property
#     def form(self):
#         return self._tag(u'form', False, True)
# 
#     @property
#     def input(self):
#         return self._tag(u'input', True)
# 
#     @property
#     def textarea(self):
#         return self._tag(u'textarea', False, True)
# 
#     @property
#     def button(self):
#         return self._tag(u'button')
# 
#     @property
#     def select(self):
#         return self._tag(u'select', False, True)
# 
#     @property
#     def option(self):
#         return self._tag(u'option', False, True)
# 
#     @property
#     def label(self):
#         return self._tag(u'label')
# 
#     def tag(self, tagname, bind=None, **kw):
#         if isinstance(tagname, str):  # pragma: nocover
#             tagname = unicode(tagname)
#         tagname = tagname.lower()
#         if bind is None and not kw:
#             return self._tag(tagname)
#         else:
#             return self._tag(tagname)(bind, **kw)
# 
#     def _tag(self, tagname, empty_in_html=False, always_paired=False):
#         if self._tags[tagname]:
#             return self._tags[tagname][-1]
#         return Tag(tagname, self, empty_in_html, always_paired)
# 
# Path: tests/markup/_util.py
# def markup_test(markup='xml', schema=None):
#     """Turn a function into a Generator markup test.
# 
#     Desired output is read from the docstring.  The function is passed a
#     generator and an Element and is expected to return output matching the
#     docstring.
# 
#     """
#     def decorator(fn):
#         expected = fn.__doc__.decode('utf8').strip()
# 
#         @wraps(fn)
#         def test():
#             from flatland.out.markup import Generator
# 
#             generator = Generator(markup=markup)
#             if schema is not None:
#                 el = schema()
#             else:
#                 el = None
#             got = fn(generator, el)
#             assert hasattr(got, '__html__')
# 
#             got = got.strip()
#             if expected != got:
#                 print "\n" + fn.__name__
#                 print "Expected:\n" + expected
#                 print "Got:\n" + got
#             assert expected == got
#         return test
#     return decorator


from flatland import String
from flatland.out.markup import Generator
from tests.markup._util import markup_test
    output_a = tag.open(el)
    contents = tag.contents
    output_b = tag.open(el)

    assert contents == tag.contents
    assert output_a == output_b

    assert gen.textarea is tag
    assert gen.textarea.contents == contents
    tag.close()
    assert gen.textarea is not tag
    assert gen.textarea.contents != contents
    tag.close()
    tag.close()


@markup_test('xml', schema)
def test_input_close(gen, el):
    """</input>"""
    return gen.input.close()


@markup_test('xml', schema)
def test_textarea_escaped(gen, el):
    '''<textarea name="field1">"&lt;quoted &amp; escaped&gt;"</textarea>'''
    bind = el
    bind.set(u'"<quoted & escaped>"')
    return gen.textarea(bind)



# 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/markup.py
# class Generator(Context):
# 
#     def __init__(self, markup='xhtml', **options):
#         Context.__init__(self)
#         if markup == 'html':
#             self.xml = False
#         elif markup in ('xhtml', 'xml'):
#             self.xml = True
#         else:
#             raise TypeError("Unknown markup type %r" % markup)
#         self._tags = defaultdict(list)
#         self._frames[-1].update(_default_options)
#         self.push()
#         self.update(options)
# 
#     def begin(self, **settings):
#         self.push(**settings)
#         return self['markup_wrapper'](u'')
# 
#     def end(self):
#         if len(self._frames) == 2:
#             raise RuntimeError("end() without matching begin()")
#         self.pop()
#         return self['markup_wrapper'](u'')
# 
#     def set(self, **settings):
#         for key, value in settings.items():
#             if key not in self:
#                 raise TypeError(
#                     "%r is not a valid argument." % key)
#             if key.startswith('auto_'):
#                 value = parse_trool(value)
#             self[key] = value
#         return self['markup_wrapper'](u'')
# 
#     @property
#     def form(self):
#         return self._tag(u'form', False, True)
# 
#     @property
#     def input(self):
#         return self._tag(u'input', True)
# 
#     @property
#     def textarea(self):
#         return self._tag(u'textarea', False, True)
# 
#     @property
#     def button(self):
#         return self._tag(u'button')
# 
#     @property
#     def select(self):
#         return self._tag(u'select', False, True)
# 
#     @property
#     def option(self):
#         return self._tag(u'option', False, True)
# 
#     @property
#     def label(self):
#         return self._tag(u'label')
# 
#     def tag(self, tagname, bind=None, **kw):
#         if isinstance(tagname, str):  # pragma: nocover
#             tagname = unicode(tagname)
#         tagname = tagname.lower()
#         if bind is None and not kw:
#             return self._tag(tagname)
#         else:
#             return self._tag(tagname)(bind, **kw)
# 
#     def _tag(self, tagname, empty_in_html=False, always_paired=False):
#         if self._tags[tagname]:
#             return self._tags[tagname][-1]
#         return Tag(tagname, self, empty_in_html, always_paired)
# 
# Path: tests/markup/_util.py
# def markup_test(markup='xml', schema=None):
#     """Turn a function into a Generator markup test.
# 
#     Desired output is read from the docstring.  The function is passed a
#     generator and an Element and is expected to return output matching the
#     docstring.
# 
#     """
#     def decorator(fn):
#         expected = fn.__doc__.decode('utf8').strip()
# 
#         @wraps(fn)
#         def test():
#             from flatland.out.markup import Generator
# 
#             generator = Generator(markup=markup)
#             if schema is not None:
#                 el = schema()
#             else:
#                 el = None
#             got = fn(generator, el)
#             assert hasattr(got, '__html__')
# 
#             got = got.strip()
#             if expected != got:
#                 print "\n" + fn.__name__
#                 print "Expected:\n" + expected
#                 print "Got:\n" + got
#             assert expected == got
#         return test
#     return decorator


# Path: tests/markup/test_generator.py
from flatland import String
from flatland.out.markup import Generator
from tests.markup._util import markup_test

    output_a = tag.open(el)
    contents = tag.contents
    output_b = tag.open(el)

    assert contents == tag.contents
    assert output_a == output_b

    assert gen.textarea is tag
    assert gen.textarea.contents == contents
    tag.close()
    assert gen.textarea is not tag
    assert gen.textarea.contents != contents
    tag.close()
    tag.close()


@markup_test('xml', schema)
def test_input_close(gen, el):
    """</input>"""
    return gen.input.close()


@markup_test('xml', schema)
def test_textarea_escaped(gen, el):
    '''<textarea name="field1">"&lt;quoted &amp; escaped&gt;"</textarea>'''
    bind = el
    bind.set(u'"<quoted & escaped>"')
    return gen.textarea(bind)



@markup_test('xml', schema)