NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

tests.py (2019B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\lib\jinja2\testsuite\tests.py
      2 import unittest
      3 from jinja2.testsuite import JinjaTestCase
      4 from jinja2 import Markup, Environment
      5 env = Environment()
      6 
      7 class TestsTestCase(JinjaTestCase):
      8 
      9     def test_defined(self):
     10         tmpl = env.from_string('{{ missing is defined }}|{{ true is defined }}')
     11 
     12     def test_even(self):
     13         tmpl = env.from_string('{{ 1 is even }}|{{ 2 is even }}')
     14 
     15     def test_odd(self):
     16         tmpl = env.from_string('{{ 1 is odd }}|{{ 2 is odd }}')
     17 
     18     def test_lower(self):
     19         tmpl = env.from_string('{{ "foo" is lower }}|{{ "FOO" is lower }}')
     20 
     21     def test_typechecks(self):
     22         tmpl = env.from_string('\n            {{ 42 is undefined }}\n            {{ 42 is defined }}\n            {{ 42 is none }}\n            {{ none is none }}\n            {{ 42 is number }}\n            {{ 42 is string }}\n            {{ "foo" is string }}\n            {{ "foo" is sequence }}\n            {{ [1] is sequence }}\n            {{ range is callable }}\n            {{ 42 is callable }}\n            {{ range(5) is iterable }}\n            {{ {} is mapping }}\n            {{ mydict is mapping }}\n            {{ [] is mapping }}\n        ')
     23 
     24         class MyDict(dict):
     25             pass
     26 
     27     def test_sequence(self):
     28         tmpl = env.from_string('{{ [1, 2, 3] is sequence }}|{{ "foo" is sequence }}|{{ 42 is sequence }}')
     29 
     30     def test_upper(self):
     31         tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}')
     32 
     33     def test_sameas(self):
     34         tmpl = env.from_string('{{ foo is sameas false }}|{{ 0 is sameas false }}')
     35 
     36     def test_no_paren_for_arg1(self):
     37         tmpl = env.from_string('{{ foo is sameas none }}')
     38 
     39     def test_escaped(self):
     40         env = Environment(autoescape=True)
     41         tmpl = env.from_string('{{ x is escaped }}|{{ y is escaped }}')
     42 
     43 
     44 def suite():
     45     suite = unittest.TestSuite()
     46     suite.addTest(unittest.makeSuite(TestsTestCase))
     47     return suite