#See http://bugs.4suite.org/1180509
import tempfile, os
from Ft.Lib import Uri
from Xml.Xslt import test_harness
SHEET_1 = """
test
hello world
"""
EXPECTED = ""
EXPECTED_FILE_1 = '\n
testhello world
'
EXPECTED_FILE_2 = '\n\n \n \n test\n \n \n hello world
\n \n'
def Test(tester):
tester.startGroup('EXSLT exsl:document and indent')
fname = tempfile.mktemp()
furi = Uri.OsPathToUri(fname)
source = test_harness.FileInfo(string="")
sheet = test_harness.FileInfo(string=SHEET_1%(furi, "no"))
test_harness.XsltTest(tester, source, [sheet], EXPECTED,
title='run transform')
tester.startTest("With indent='no'")
tester.compare(True, os.path.exists(fname))
file = open(fname, 'r')
fcontent = file.read()
file.close()
tester.compare(EXPECTED_FILE_1, fcontent)
os.unlink(fname)
tester.testDone()
fname = tempfile.mktemp()
furi = Uri.OsPathToUri(fname)
source = test_harness.FileInfo(string="")
sheet = test_harness.FileInfo(string=SHEET_1%(furi, "yes"))
test_harness.XsltTest(tester, source, [sheet], EXPECTED,
title='run transform')
tester.startTest("With indent='yes'")
tester.compare(True, os.path.exists(fname))
file = open(fname, 'r')
fcontent = file.read()
file.close()
tester.compare(EXPECTED_FILE_2, fcontent)
os.unlink(fname)
tester.testDone()
tester.groupDone()
return