"""
Tests stringify functions used in xmodule html
"""
from nose.tools import assert_equals # pylint: disable=no-name-in-module
from lxml import etree
from xmodule.stringify import stringify_children
def test_stringify():
text = 'Hi
there Bruce!
'
html = '''{0}'''.format(text)
xml = etree.fromstring(html)
out = stringify_children(xml)
assert_equals(out, text)
def test_stringify_again():
html = r"""A voltage source is non-linear!

\(V=V_C\)
But it is affine,
which means linear except for an offset.
"""
html = """A voltage source is non-linear!
But it is affine,
which means linear except for an offset.
"""
xml = etree.fromstring(html)
out = stringify_children(xml)
print "output:"
print out
# Tracking strange content repeating bug
# Should appear once
assert_equals(out.count("But it is "), 1)