mirror of https://github.com/zulip/zulip.git
Finish annotating template/css parsers and tests.
This commit is contained in:
parent
e580ed579b
commit
1eb16d03a2
|
@ -25,6 +25,7 @@ class Token(object):
|
||||||
self.col = col
|
self.col = col
|
||||||
|
|
||||||
def tokenize(text):
|
def tokenize(text):
|
||||||
|
# type: (str) -> List[Token]
|
||||||
def advance(n):
|
def advance(n):
|
||||||
# type: (int) -> None
|
# type: (int) -> None
|
||||||
for _ in range(n):
|
for _ in range(n):
|
||||||
|
@ -119,7 +120,7 @@ def tokenize(text):
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
def validate(fn=None, text=None, check_indent=True):
|
def validate(fn=None, text=None, check_indent=True):
|
||||||
# type: (str, str, bool) -> None
|
# type: (Optional[str], Optional[str], bool) -> None
|
||||||
assert fn or text
|
assert fn or text
|
||||||
|
|
||||||
if fn is None:
|
if fn is None:
|
||||||
|
|
|
@ -119,9 +119,8 @@ class ParserTestSadPath(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def _assert_error(self, my_css, error):
|
def _assert_error(self, my_css, error):
|
||||||
# See https://github.com/python/typeshed/issues/372
|
# type: (str, str) -> None
|
||||||
# for why we have to ingore types here.
|
with self.assertRaisesRegexp(CssParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
||||||
with self.assertRaisesRegexp(CssParserException, error): # type: ignore
|
|
||||||
parse(my_css)
|
parse(my_css)
|
||||||
|
|
||||||
def test_unexpected_end_brace(self):
|
def test_unexpected_end_brace(self):
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -17,9 +19,8 @@ except ImportError:
|
||||||
|
|
||||||
class ParserTest(unittest.TestCase):
|
class ParserTest(unittest.TestCase):
|
||||||
def _assert_validate_error(self, error, fn=None, text=None, check_indent=True):
|
def _assert_validate_error(self, error, fn=None, text=None, check_indent=True):
|
||||||
# See https://github.com/python/typeshed/issues/372
|
# type: (str, Optional[str], Optional[str], bool) -> None
|
||||||
# for why we have to ingore types here.
|
with self.assertRaisesRegexp(TemplateParserException, error): # type: ignore # See https://github.com/python/typeshed/issues/372
|
||||||
with self.assertRaisesRegexp(TemplateParserException, error): # type: ignore
|
|
||||||
validate(fn=fn, text=text, check_indent=check_indent)
|
validate(fn=fn, text=text, check_indent=check_indent)
|
||||||
|
|
||||||
def test_is_django_block_tag(self):
|
def test_is_django_block_tag(self):
|
||||||
|
|
Loading…
Reference in New Issue