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