Commit 42c157b9 authored by Evan Simpson's avatar Evan Simpson

Fix tests to match new TAL default of omitting attribute languages

parent 51d88f6d
......@@ -98,12 +98,13 @@
import string
if sys.modules.has_key('unittest'):
# The framework should already be set up
pass
else:
scriptdir = sys.path[0]
if scriptdir == '':
scriptdir = sys.path[0]
input_dir = os.path.join(scriptdir, 'input')
output_dir = os.path.join(scriptdir, 'output')
if not sys.modules.has_key('unittest'):
if os.path.abspath(scriptdir) == os.path.abspath('.'):
# We're in the tests directory, and need to find unittest.
cwd = os.getcwd()
while 1:
for ext in 'py', 'pyc', 'pyo', 'pyd':
......@@ -116,16 +117,27 @@ else:
break
sys.path.insert(1, cwd)
else:
# We must be in the same directory as unittest
sys.path.insert(1, '')
import unittest
import unittest
TestRunner = unittest.TextTestRunner
def read_input(filename):
filename = os.path.join(input_dir, filename)
return open(filename, 'r').read()
def read_output(filename):
filename = os.path.join(output_dir, filename)
return open(filename, 'r').read()
def main():
if len(sys.argv) > 1:
globals()[sys.argv[1]]()
errs = globals()[sys.argv[1]]()
else:
TestRunner().run(test_suite())
errs = TestRunner().run(test_suite())
sys.exit(errs and 1 or 0)
def debug():
test_suite().debug()
......
<html>
<head></head>
<body>
<div tal:content="not:python:0">1</div>
<div tal:content="not:python:1">0</div>
<div tal:content="not: python:1">0</div>
<div tal:content="not:python:range(1,20)">0</div>
<div>1</div>
<div>0</div>
<div>0</div>
<div>0</div>
</body>
</html>
<html>
<body>
<head>
<title tal:content="nothing"></title>
<title></title>
</head>
</body>
</html>
<html>
<body>
<head>
<title tal:content="path:nothing"></title>
<title></title>
</head>
</body>
</html>
<?xml version="1.0" ?>
<html>
<body tal:content="string:Hello!">Hello!</body>
<body>Hello!</body>
</html>
<html xmlns:tal="http://xml.zope.org/namespaces/tal">
<html>
<head><title>Test of documentation templates</title></head>
<body>
<dl tal:condition="here/args">
<dl>
<dt>The arguments to this test program were:</dt>
<dd>
<ul>
<li tal:repeat="arg here/args">
<li>
Argument number 1
is one
</li><li tal:repeat="arg here/args">
</li><li>
Argument number 2
is two
</li><li tal:repeat="arg here/args">
</li><li>
Argument number 3
is three
</li><li tal:repeat="arg here/args">
</li><li>
Argument number 4
is cha
</li><li tal:repeat="arg here/args">
</li><li>
Argument number 5
is cha
</li><li tal:repeat="arg here/args">
</li><li>
Argument number 6
is cha
</li>
......
<html xmlns:tal="http://xml.zope.org/namespaces/tal">
<html>
<head><title>Test of documentation templates</title></head>
<body>
<p tal:condition="not:here/args">No arguments were given.</p>
<p>No arguments were given.</p>
And thats da trooth.
</body>
</html>
<head><title>Test of documentation templates</title></head>
<body>
<div tal:condition="here/args">
<div>
The arguments were:
<dl>
<span tal:repeat="arg options/batch">
<span>
<dt>one.</dt>
<dd>Argument 1 was one</dd>
</span><span tal:repeat="arg options/batch">
</span><span>
<dt>two.</dt>
<dd>Argument 2 was two</dd>
</span><span tal:repeat="arg options/batch">
</span><span>
<dt>three.</dt>
<dd>Argument 3 was three</dd>
</span><span tal:repeat="arg options/batch">
</span><span>
<dt>four.</dt>
<dd>Argument 4 was four</dd>
</span><span tal:repeat="arg options/batch">
</span><span>
<dt>five.</dt>
<dd>Argument 5 was five</dd>
</span>
</dl>
<span tal:condition="options/batch/next_sequence">
<span>
(six-ten)
</span>
</div>
......
<html tal:define="global x python:1">
<html>
<head></head>
<body>
<div tal:define="x python:2">
<span tal:content="x">2</span>
<div>
<span>2</span>
</div>
<div>
<span tal:content="x">1</span>
<span>1</span>
</div>
<div tal:define="global x python:3">
<span tal:content="x">3</span>
<div>
<span>3</span>
</div>
</body>
</html>
......@@ -5,20 +5,14 @@
<body>
<p>Choose your type:</p>
<ul>
<li tal:repeat="type python:'digital', 'analog', 'organic'">
<a href="/mach/digital"
tal:attributes="href string:/mach/$type"
tal:content="type">digital</a>
<li>
<a href="/mach/digital">digital</a>
</li>
<li tal:repeat="type python:'digital', 'analog', 'organic'">
<a href="/mach/analog"
tal:attributes="href string:/mach/$type"
tal:content="type">analog</a>
<li>
<a href="/mach/analog">analog</a>
</li>
<li tal:repeat="type python:'digital', 'analog', 'organic'">
<a href="/mach/organic"
tal:attributes="href string:/mach/$type"
tal:content="type">organic</a>
<li>
<a href="/mach/organic">organic</a>
</li>
</ul>
</body>
......
<html>
<body>
<head>
<title tal:content="string:Hello World!">Hello World!</title>
<title>Hello World!</title>
</head>
</body>
</html>
<html metal:use-macro="container/laf/macros/page">
<html>
<head>
<title>Zope Stuff</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
......@@ -28,7 +28,7 @@
</table>
<br>
<br>
<div metal:fill-slot="body">
<div>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#0000CC">
......@@ -36,7 +36,7 @@
<tr bgcolor="#FFFFFF" align="center">
<td><img src="/images/welcome.gif" width="293" height="28"></td>
</tr>
<tr bgcolor="#FFFFFF" align="center" valign="top" tal:repeat="product options/getProducts">
<tr bgcolor="#FFFFFF" align="center" valign="top">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
......@@ -44,8 +44,7 @@
</b>This is the tee for those who LOVE Zope. Show your heart on your tee.</td>
<td align="right" width="1%" rowspan="2">
<p><img src="/images/smlatee.jpg"
width="200" height="200"
tal:attributes="src string:/images/${product/image}"></p>
width="200" height="200"></p>
</td>
</tr>
<tr>
......@@ -55,7 +54,7 @@
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF" align="center" valign="top" tal:repeat="product options/getProducts">
<tr bgcolor="#FFFFFF" align="center" valign="top">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
......@@ -63,8 +62,7 @@
</b>This is the tee for Jim Fulton. He's the Zope Pope!</td>
<td align="right" width="1%" rowspan="2">
<p><img src="/images/smpztee.jpg"
width="200" height="200"
tal:attributes="src string:/images/${product/image}"></p>
width="200" height="200"></p>
</td>
</tr>
<tr>
......
<html metal:use-macro="container/laf/macros/page">
<html>
<head>
<title>Zope Stuff</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
......@@ -28,7 +28,7 @@
</table>
<br>
<br>
<div metal:fill-slot="body">
<div>
Body
</div>
<br><br>
......
<html metal:define-macro="page">
<html>
<head>
<title>Zope Stuff</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
......@@ -28,7 +28,7 @@
</table>
<br>
<br>
<div metal:define-slot="body">
<div>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#0000CC">
......
#! /usr/bin/env python1.5
"""Run all tests."""
import os, sys
execfile(os.path.join(sys.path[0], 'framework.py'))
def test_suite():
suite = unittest.TestSuite()
for mname in ('DTMLTests', 'HTMLTests', 'Expressions', 'TALES'):
m = __import__('test' + mname)
suite.addTest(m.test_suite())
return suite
if __name__ == "__main__":
main()
......@@ -120,18 +120,18 @@ class DTMLTests(unittest.TestCase):
</body></html>
"""
tal = open('input/DTML1.html').read()
tal = read_input('DTML1.html')
self.t.write(tal)
aa=util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha'))
o=self.t.__of__(aa)()
expect = open('output/DTML1a.html').read()
expect = read_output('DTML1a.html')
util.check_xml(expect, o)
aa=util.argv(())
o=self.t.__of__(aa)()
expect = open('output/DTML1b.html').read()
expect = read_output('DTML1b.html')
util.check_xml(expect, o)
def check3(self):
......@@ -164,7 +164,7 @@ class DTMLTests(unittest.TestCase):
</body></html>
"""
tal = open('input/DTML3.html').read()
tal = read_input('DTML3.html')
self.t.write(tal)
aa=util.argv(('one', 'two', 'three', 'four', 'five',
......@@ -175,7 +175,7 @@ class DTMLTests(unittest.TestCase):
import batch
o=self.t.__of__(aa)(batch=batch.batch(aa.args, 5))
expect = open('output/DTML3.html').read()
expect = read_output('DTML3.html')
util.check_xml(expect, o)
def test_suite():
......
......@@ -117,75 +117,75 @@ class HTMLTests(unittest.TestCase):
def check1(self):
laf = self.folder.laf
laf.write(open('input/TeeShopLAF.html').read())
expect = open('output/TeeShopLAF.html').read()
laf.write(read_input('TeeShopLAF.html'))
expect = read_output('TeeShopLAF.html')
util.check_html(expect, laf())
def check2(self):
self.folder.laf.write(open('input/TeeShopLAF.html').read())
self.folder.laf.write(read_input('TeeShopLAF.html'))
t = self.folder.t
t.write(open('input/TeeShop2.html').read())
expect = open('output/TeeShop2.html').read()
t.write(read_input('TeeShop2.html'))
expect = read_output('TeeShop2.html')
out = t(getProducts=self.getProducts)
util.check_html(expect, out)
def check3(self):
self.folder.laf.write(open('input/TeeShopLAF.html').read())
self.folder.laf.write(read_input('TeeShopLAF.html'))
t = self.folder.t
t.write(open('input/TeeShop1.html').read())
expect = open('output/TeeShop1.html').read()
t.write(read_input('TeeShop1.html'))
expect = read_output('TeeShop1.html')
out = t(getProducts=self.getProducts)
util.check_html(expect, out)
def checkSimpleLoop(self):
t = self.folder.t
t.write(open('input/Loop1.html').read())
expect = open('output/Loop1.html').read()
t.write(read_input('Loop1.html'))
expect = read_output('Loop1.html')
out = t()
util.check_html(expect, out)
def checkGlobalsShadowLocals(self):
t = self.folder.t
t.write(open('input/GlobalsShadowLocals.html').read())
expect = open('output/GlobalsShadowLocals.html').read()
t.write(read_input('GlobalsShadowLocals.html'))
expect = read_output('GlobalsShadowLocals.html')
out = t()
util.check_html(expect, out)
def checkStringExpressions(self):
t = self.folder.t
t.write(open('input/StringExpression.html').read())
expect = open('output/StringExpression.html').read()
t.write(read_input('StringExpression.html'))
expect = read_output('StringExpression.html')
out = t()
util.check_html(expect, out)
def checkReplaceWithNothing(self):
t = self.folder.t
t.write(open('input/CheckNothing.html').read())
expect = open('output/CheckNothing.html').read()
t.write(read_input('CheckNothing.html'))
expect = read_output('CheckNothing.html')
out = t()
util.check_html(expect, out)
def checkWithXMLHeader(self):
t = self.folder.t
t.write(open('input/CheckWithXMLHeader.html').read())
expect = open('output/CheckWithXMLHeader.html').read()
t.write(read_input('CheckWithXMLHeader.html'))
expect = read_output('CheckWithXMLHeader.html')
out = t()
util.check_html(expect, out)
def checkNotExpression(self):
t = self.folder.t
t.write(open('input/CheckNotExpression.html').read())
expect = open('output/CheckNotExpression.html').read()
t.write(read_input('CheckNotExpression.html'))
expect = read_output('CheckNotExpression.html')
out = t()
util.check_html(expect, out)
def checkPathNothing(self):
t = self.folder.t
t.write(open('input/CheckPathNothing.html').read())
expect = open('output/CheckPathNothing.html').read()
t.write(read_input('CheckPathNothing.html'))
expect = read_output('CheckPathNothing.html')
out = t()
util.check_html(expect, out)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment