Fix inline html bug.

* problem was in trying to remove the outer <html> + </html> tags.
* cleaned up the stringify function to be less magical, and more
  obviously correct.

[Fix #35136297]
This commit is contained in:
Victor Shnayder
2012-08-28 19:51:25 -04:00
parent cbfc117e8b
commit fe50f94437
2 changed files with 42 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from nose.tools import assert_equals
from nose.tools import assert_equals, assert_true, assert_false
from lxml import etree
from xmodule.stringify import stringify_children
@@ -8,3 +8,32 @@ def test_stringify():
xml = etree.fromstring(html)
out = stringify_children(xml)
assert_equals(out, text)
def test_stringify_again():
html = """<html name="Voltage Source Answer" >A voltage source is non-linear!
<div align="center">
<img src="/static/images/circuits/voltage-source.png"/>
\(V=V_C\)
</div>
But it is <a href="http://mathworld.wolfram.com/AffineFunction.html">affine</a>,
which means linear except for an offset.
</html>
"""
html = """<html>A voltage source is non-linear!
<div align="center">
</div>
But it is <a href="http://mathworld.wolfram.com/AffineFunction.html">affine</a>,
which means linear except for an offset.
</html>
"""
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)