# tests URL: /api/environment/tests/ Section: environment -------------------------------------------------------------------------------- tests - Kida window.BENGAL_THEME_DEFAULTS = { appearance: 'light', palette: 'brown-bengal' }; window.Bengal = window.Bengal || {}; window.Bengal.enhanceBaseUrl = '/kida/assets/js/enhancements'; window.Bengal.watchDom = true; window.Bengal.debug = false; window.Bengal.enhanceUrls = { 'toc': '/kida/assets/js/enhancements/toc.632a9783.js', 'docs-nav': '/kida/assets/js/enhancements/docs-nav.57e4b129.js', 'tabs': '/kida/assets/js/enhancements/tabs.aac9e817.js', 'lightbox': '/kida/assets/js/enhancements/lightbox.1ca22aa1.js', 'interactive': '/kida/assets/js/enhancements/interactive.fc077855.js', 'mobile-nav': '/kida/assets/js/enhancements/mobile-nav.d991657f.js', 'action-bar': '/kida/assets/js/enhancements/action-bar.d62417f4.js', 'copy-link': '/kida/assets/js/enhancements/copy-link.7d9a5c29.js', 'data-table': '/kida/assets/js/enhancements/data-table.1f5bc1eb.js', 'lazy-loaders': '/kida/assets/js/enhancements/lazy-loaders.a5c38245.js', 'holo': '/kida/assets/js/enhancements/holo.ee13c841.js', 'link-previews': '/kida/assets/js/enhancements/link-previews.8d906535.js' }; (function () { try { var defaults = window.BENGAL_THEME_DEFAULTS || { appearance: 'system', palette: '' }; var defaultAppearance = defaults.appearance; if (defaultAppearance === 'system') { defaultAppearance = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } var storedTheme = localStorage.getItem('bengal-theme'); var storedPalette = localStorage.getItem('bengal-palette'); var theme = storedTheme ? (storedTheme === 'system' ? defaultAppearance : storedTheme) : defaultAppearance; var palette = storedPalette ?? defaults.palette; document.documentElement.setAttribute('data-theme', theme); if (palette) { document.documentElement.setAttribute('data-palette', palette); } } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); } })(); { "prerender": [ { "where": { "and": [ { "href_matches": "/docs/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ], "prefetch": [ { "where": { "and": [ { "href_matches": "/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ] } Skip to main content Magnifying Glass ESC Recent Clear Magnifying Glass No results for "" Start typing to search... ↑↓ Navigate ↵ Open ESC Close Powered by Lunr )彡 DocumentationInfoAboutArrow ClockwiseGet StartedCodeSyntaxTerminalUsageNoteTutorialsStarburstExtendingBookmarkReferenceTroubleshootingReleasesDevGitHubKida API Reference Magnifying Glass Search ⌘K Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal List )彡 Magnifying Glass Search X Close Documentation Caret Down Info About Arrow Clockwise Get Started Code Syntax Terminal Usage Note Tutorials Starburst Extending Bookmark Reference Troubleshooting Releases Dev Caret Down GitHub Kida API Reference Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal Kida API Reference Caret Right Analysis analyzer cache config dependencies landmarks metadata purity roles Caret Right Compiler Caret Right Statements basic control_flow functions special_blocks template_structure variables _protocols coalescing core expressions utils Caret Right Environment core exceptions filters loaders protocols registry tests Caret Right Parser Caret Right Blocks control_flow core functions special_blocks template_structure variables _protocols core errors expressions statements tokens Caret Right Utils html lru_cache workers _types bytecode_cache kida lexer nodes template tstring Kida API ReferenceEnvironment ᗢ Caret Down Link Copy URL External Open LLM text Copy Copy LLM text Share with AI Ask Claude Ask ChatGPT Ask Gemini Ask Copilot Module environment.tests Built-in tests for Kida templates. Tests are boolean predicates used with is in conditionals: {% if value is test %} or {% if value is test(arg) %} Categories: Type Tests: defined: Value is not None undefined: Value is None none: Value is None (alias) string: Value is a string number: Value is int or float (not bool) sequence: Value is list, tuple, or string mapping: Value is a dict iterable: Value supports iteration callable: Value is callable Boolean Tests: true: Value is exactly True false: Value is exactly False Number Tests: odd: Integer is odd even: Integer is even divisibleby(n): Integer is divisible by n Comparison Tests: eq(other) / equalto(other): Equal to other ne(other): Not equal to other lt(other) / lessthan(other): Less than other le(other): Less than or equal gt(other) / greaterthan(other): Greater than other ge(other): Greater than or equal sameas(other): Identity comparison (is) in(seq): Value is in sequence String Tests: lower: String is all lowercase upper: String is all uppercase Negation: Use is not for negated tests: {% if user is not defined %} or {% if count is not even %} Example: ```jinja {% if posts is defined and posts is iterable %} {% for post in posts %} {% if loop.index is odd %} <div class="odd">{{ post.title }}</div> {% endif %} {% endfor %} {% endif %} ``` Custom Tests: >>> env.add_test('prime', lambda n: n > 1 and all(n % i for i in range(2, n))) >>> # {% if 17 is prime %}Yes{% endif %} 22Functions Functions _apply_test 2 bool ▼ Apply a test to a value. def _apply_test(value: Any, test_name: str, *args: Any) -> bool Parameters Name Type Description value Any test_name str Returns bool _test_callable 1 bool ▼ Test if value is callable. def _test_callable(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_defined 1 bool ▼ Test if value is defined (not None). def _test_defined(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_divisible_by 2 bool ▼ Test if value is divisible by num. def _test_divisible_by(value: int, num: int) -> bool Parameters Name Type Description value int num int Returns bool _test_eq 2 bool ▼ Test equality. def _test_eq(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_even 1 bool ▼ Test if value is even. def _test_even(value: int) -> bool Parameters Name Type Description value int Returns bool _test_ge 2 bool ▼ Test greater than or equal. def _test_ge(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_gt 2 bool ▼ Test greater than. def _test_gt(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_in 2 bool ▼ Test if value is in sequence. def _test_in(value: Any, seq: Any) -> bool Parameters Name Type Description value Any seq Any Returns bool _test_iterable 1 bool ▼ Test if value is iterable. def _test_iterable(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_le 2 bool ▼ Test less than or equal. def _test_le(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_lower 1 bool ▼ Test if string is lowercase. def _test_lower(value: str) -> bool Parameters Name Type Description value str Returns bool _test_lt 2 bool ▼ Test less than. def _test_lt(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_mapping 1 bool ▼ Test if value is a mapping. def _test_mapping(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_ne 2 bool ▼ Test inequality. def _test_ne(value: Any, other: Any) -> bool Parameters Name Type Description value Any other Any Returns bool _test_none 1 bool ▼ Test if value is None. def _test_none(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_number 1 bool ▼ Test if value is a number. def _test_number(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_odd 1 bool ▼ Test if value is odd. def _test_odd(value: int) -> bool Parameters Name Type Description value int Returns bool _test_sequence 1 bool ▼ Test if value is a sequence. def _test_sequence(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_string 1 bool ▼ Test if value is a string. def _test_string(value: Any) -> bool Parameters Name Type Description value Any Returns bool _test_upper 1 bool ▼ Test if string is uppercase. def _test_upper(value: str) -> bool Parameters Name Type Description value str Returns bool _test_match 2 bool ▼ Test if string matches regex pattern. Used by rejectattr/selectattr for filter… def _test_match(value: Any, pattern: str) -> bool Test if string matches regex pattern. Used by rejectattr/selectattr for filtering by regex pattern. Parameters Name Type Description value Any pattern str Returns bool ← Previous registry List © 2026 Kida built in ᓚᘏᗢ { "linkPreviews": { "enabled": true, "hoverDelay": 200, "hideDelay": 150, "showSection": true, "showReadingTime": true, "showWordCount": true, "showDate": true, "showTags": true, "maxTags": 3, "includeSelectors": [".prose"], "excludeSelectors": ["nav", ".toc", ".breadcrumb", ".pagination", ".card", "[class*='-card']", ".tab-nav", "[class*='-widget']", ".child-items", ".content-tiles"], "allowedHosts": [], "allowedSchemes": ["https"], "hostFailureThreshold": 3 } } window.BENGAL_LAZY_ASSETS = { tabulator: '/kida/assets/js/tabulator.min.js', dataTable: '/kida/assets/js/data-table.js', mermaidToolbar: '/kida/assets/js/mermaid-toolbar.9de5abba.js', mermaidTheme: '/kida/assets/js/mermaid-theme.344822c5.js', graphMinimap: '/kida/assets/js/graph-minimap.ff04e939.js', graphContextual: '/kida/assets/js/graph-contextual.355458ba.js' }; window.BENGAL_ICONS = { close: '/kida/assets/icons/close.911d4fe1.svg', enlarge: '/kida/assets/icons/enlarge.652035e5.svg', copy: '/kida/assets/icons/copy.3d56e945.svg', 'download-svg': '/kida/assets/icons/download.04f07e1b.svg', 'download-png': '/kida/assets/icons/image.c34dfd40.svg', 'zoom-in': '/kida/assets/icons/zoom-in.237b4a83.svg', 'zoom-out': '/kida/assets/icons/zoom-out.38857c77.svg', reset: '/kida/assets/icons/reset.d26dba29.svg' }; Arrow Up -------------------------------------------------------------------------------- Metadata: - Word Count: 1293 - Reading Time: 6 minutes