Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-mako
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-mako
Commits
53b62023
Commit
53b62023
authored
10 years ago
by
Wichert Akkerman
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for Babel plugin
parent
285bc818
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
setup.py
+1
-1
1 addition, 1 deletion
setup.py
test/ext/__init__.py
+0
-0
0 additions, 0 deletions
test/ext/__init__.py
test/ext/test_babelplugin.py
+48
-0
48 additions, 0 deletions
test/ext/test_babelplugin.py
with
49 additions
and
1 deletion
setup.py
+
1
−
1
View file @
53b62023
...
...
@@ -47,7 +47,7 @@ setup(name='Mako',
url
=
'
http://www.makotemplates.org/
'
,
license
=
'
MIT
'
,
packages
=
find_packages
(
'
.
'
,
exclude
=
[
'
examples*
'
,
'
test*
'
]),
tests_require
=
[
'
nose >= 0.11
'
,
'
mock
'
],
tests_require
=
[
'
nose >= 0.11
'
,
'
mock
'
,
'
Babel
'
],
test_suite
=
"
nose.collector
"
,
zip_safe
=
False
,
install_requires
=
install_requires
,
...
...
This diff is collapsed.
Click to expand it.
test/ext/__init__.py
0 → 100644
+
0
−
0
View file @
53b62023
This diff is collapsed.
Click to expand it.
test/ext/test_babelplugin.py
0 → 100644
+
48
−
0
View file @
53b62023
import
io
import
mock
import
unittest
from
mako.ext.babelplugin
import
_split_comment
from
mako.ext.babelplugin
import
extract
from
mako.ext.babelplugin
import
extract_nodes
class
Test_extract
(
unittest
.
TestCase
):
def
test_parse_and_invoke_extract_nodes
(
self
):
input
=
io
.
BytesIO
(
b
'
<p>Hello world</p>
'
)
with
mock
.
patch
(
'
mako.ext.babelplugin.extract_nodes
'
)
as
extract_nodes
:
list
(
extract
(
input
,
[],
[],
{}))
extract_nodes
.
assert_called_once_with
([
mock
.
ANY
],
[],
[],
{})
self
.
assertEqual
(
extract_nodes
.
mock_calls
[
0
][
1
][
0
][
0
].
content
,
u
'
<p>Hello world</p>
'
)
def
test_parse_python_expression
(
self
):
input
=
io
.
BytesIO
(
b
'
<p>${_(
"
Message
"
)}</p>
'
)
messages
=
list
(
extract
(
input
,
[
'
_
'
],
[],
{}))
self
.
assertEqual
(
messages
,
[(
1
,
'
_
'
,
u
'
Message
'
,
[])])
def
test_python_gettext_call
(
self
):
input
=
io
.
BytesIO
(
b
'
<p>${_(
"
Message
"
)}</p>
'
)
messages
=
list
(
extract
(
input
,
[
'
_
'
],
[],
{}))
self
.
assertEqual
(
messages
,
[(
1
,
'
_
'
,
u
'
Message
'
,
[])])
def
test_translator_comment
(
self
):
input
=
io
.
BytesIO
(
b
'''
<p>
## TRANSLATORS: This is a comment.
${_(
"
Message
"
)}
</p>
'''
)
messages
=
list
(
extract
(
input
,
[
'
_
'
],
[
'
TRANSLATORS:
'
],
{}))
self
.
assertEqual
(
messages
,
[(
4
,
'
_
'
,
u
'
Message
'
,
[
u
'
TRANSLATORS: This is a comment.
'
])])
class
Test_split_comment
(
unittest
.
TestCase
):
def
test_empty_input
(
self
):
self
.
assertEqual
(
_split_comment
(
1
,
''
),
[])
def
test_multiple_lines
(
self
):
self
.
assertEqual
(
_split_comment
(
5
,
'
one
\n
two
\n
three
'
),
[(
5
,
'
one
'
),
(
6
,
'
two
'
),
(
7
,
'
three
'
)])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment