Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d1a02b0a
Commit
d1a02b0a
authored
Apr 06, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for various TALError and METALError exceptions.
parent
baa68c50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
lib/python/TAL/test/test_htmltalparser.py
lib/python/TAL/test/test_htmltalparser.py
+33
-1
lib/python/TAL/tests/test_htmltalparser.py
lib/python/TAL/tests/test_htmltalparser.py
+33
-1
No files found.
lib/python/TAL/test/test_htmltalparser.py
View file @
d1a02b0a
...
...
@@ -8,7 +8,7 @@ import utils
import
unittest
from
TAL
import
HTMLTALParser
from
TAL.TALDefs
import
TAL_VERSION
from
TAL.TALDefs
import
TAL_VERSION
,
TALError
,
METALError
class
TestCaseBase
(
unittest
.
TestCase
):
...
...
@@ -40,6 +40,12 @@ class TestCaseBase(unittest.TestCase):
pprint
.
pprint
(
got_program
)
pprint
.
pprint
(
got_macros
)
def
_should_error
(
self
,
source
,
exc
=
TALError
):
def
parse
(
self
=
self
,
source
=
source
):
parser
=
HTMLTALParser
.
HTMLTALParser
()
parser
.
parseString
(
self
.
prologue
+
source
+
self
.
epilogue
)
self
.
assertRaises
(
exc
,
parse
)
class
HTMLTALParserTestCases
(
TestCaseBase
):
...
...
@@ -349,6 +355,32 @@ class TALGeneratorTestCases(TestCaseBase):
(
'rawtext'
,
'</p>'
)]),
])
def
check_dup_attr
(
self
):
self
.
_should_error
(
"<img tal:condition='x' tal:condition='x'>"
)
self
.
_should_error
(
"<img metal:define-macro='x' "
"metal:define-macro='x'>"
,
METALError
)
def
check_tal_errors
(
self
):
self
.
_should_error
(
"<p tal:define='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x' />"
)
self
.
_should_error
(
"<p tal:foobar='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x y' tal:content='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x y' tal:replace='x' />"
)
self
.
_should_error
(
"<p tal:replace='x' tal:content='x' />"
)
self
.
_should_error
(
"<p tal:replace='x'>"
)
def
check_metal_errors
(
self
):
exc
=
METALError
self
.
_should_error
(
2
*
"<p metal:define-macro='x'>xxx</p>"
,
exc
)
## self._should_error("<html metal:define-macro='x'>" +
## 2*"<p metal:define-slot='y' />" + "</html>")
self
.
_should_error
(
"<html metal:use-macro='x'>"
+
2
*
"<p metal:fill-slot='y' />"
+
"</html>"
,
exc
)
self
.
_should_error
(
"<p metal:foobar='x' />"
,
exc
)
self
.
_should_error
(
"<p metal:define-slot='x' metal:fill-slot='x' />"
,
exc
)
self
.
_should_error
(
"<p metal:define-macro='x'>"
,
exc
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
lib/python/TAL/tests/test_htmltalparser.py
View file @
d1a02b0a
...
...
@@ -8,7 +8,7 @@ import utils
import
unittest
from
TAL
import
HTMLTALParser
from
TAL.TALDefs
import
TAL_VERSION
from
TAL.TALDefs
import
TAL_VERSION
,
TALError
,
METALError
class
TestCaseBase
(
unittest
.
TestCase
):
...
...
@@ -40,6 +40,12 @@ class TestCaseBase(unittest.TestCase):
pprint
.
pprint
(
got_program
)
pprint
.
pprint
(
got_macros
)
def
_should_error
(
self
,
source
,
exc
=
TALError
):
def
parse
(
self
=
self
,
source
=
source
):
parser
=
HTMLTALParser
.
HTMLTALParser
()
parser
.
parseString
(
self
.
prologue
+
source
+
self
.
epilogue
)
self
.
assertRaises
(
exc
,
parse
)
class
HTMLTALParserTestCases
(
TestCaseBase
):
...
...
@@ -349,6 +355,32 @@ class TALGeneratorTestCases(TestCaseBase):
(
'rawtext'
,
'</p>'
)]),
])
def
check_dup_attr
(
self
):
self
.
_should_error
(
"<img tal:condition='x' tal:condition='x'>"
)
self
.
_should_error
(
"<img metal:define-macro='x' "
"metal:define-macro='x'>"
,
METALError
)
def
check_tal_errors
(
self
):
self
.
_should_error
(
"<p tal:define='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x' />"
)
self
.
_should_error
(
"<p tal:foobar='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x y' tal:content='x' />"
)
self
.
_should_error
(
"<p tal:repeat='x y' tal:replace='x' />"
)
self
.
_should_error
(
"<p tal:replace='x' tal:content='x' />"
)
self
.
_should_error
(
"<p tal:replace='x'>"
)
def
check_metal_errors
(
self
):
exc
=
METALError
self
.
_should_error
(
2
*
"<p metal:define-macro='x'>xxx</p>"
,
exc
)
## self._should_error("<html metal:define-macro='x'>" +
## 2*"<p metal:define-slot='y' />" + "</html>")
self
.
_should_error
(
"<html metal:use-macro='x'>"
+
2
*
"<p metal:fill-slot='y' />"
+
"</html>"
,
exc
)
self
.
_should_error
(
"<p metal:foobar='x' />"
,
exc
)
self
.
_should_error
(
"<p metal:define-slot='x' metal:fill-slot='x' />"
,
exc
)
self
.
_should_error
(
"<p metal:define-macro='x'>"
,
exc
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment