How to use include method in Slash

Best Python code snippet using slash

BUILD

Source:BUILD Github

copy

Full Screen

1# A build file to configure python remote repository used with Bazel remote2# execution service3# DO NOT EDIT: automatically generated BUILD file4licenses(["restricted"])5package(default_visibility = ["//visibility:public"])6cc_library(7 name = "python_headers",8 hdrs = [":python_include"],9 data = select({10 ":windows": [":python_import_lib"],11 "//conditions:default": [],12 }),13 includes = ["python_include"],14 linkopts = select({15 # TODO(pcloudy): Ideally, this should just go into deps after resolving16 # https://github.com/bazelbuild/bazel/issues/3237,17 ":windows": ["$(locations :python_import_lib)"],18 "//conditions:default": [],19 }),20)21cc_library(22 name = "numpy_headers",23 hdrs = [":numpy_include"],24 includes = ["numpy_include"],25)26config_setting(27 name = "windows",28 values = {"cpu": "x64_windows"},29 visibility = ["//visibility:public"],30)31genrule(32 name = "python_include",33 outs = [34 "python_include/code.h",35 "python_include/dtoa.h",36 "python_include/tupleobject.h",37 "python_include/object.h",38 "python_include/ast.h",39 "python_include/pymacconfig.h",40 "python_include/errcode.h",41 "python_include/frameobject.h",42 "python_include/pgenheaders.h",43 "python_include/cellobject.h",44 "python_include/intobject.h",45 "python_include/pythread.h",46 "python_include/cStringIO.h",47 "python_include/boolobject.h",48 "python_include/modsupport.h",49 "python_include/import.h",50 "python_include/pymath.h",51 "python_include/node.h",52 "python_include/funcobject.h",53 "python_include/eval.h",54 "python_include/longintrepr.h",55 "python_include/floatobject.h",56 "python_include/rangeobject.h",57 "python_include/pyfpe.h",58 "python_include/pystrcmp.h",59 "python_include/dictobject.h",60 "python_include/pyarena.h",61 "python_include/objimpl.h",62 "python_include/bitset.h",63 "python_include/memoryobject.h",64 "python_include/bytearrayobject.h",65 "python_include/pydebug.h",66 "python_include/pyerrors.h",67 "python_include/weakrefobject.h",68 "python_include/grammar.h",69 "python_include/symtable.h",70 "python_include/longobject.h",71 "python_include/structmember.h",72 "python_include/enumobject.h",73 "python_include/classobject.h",74 "python_include/unicodeobject.h",75 "python_include/sliceobject.h",76 "python_include/pystrtod.h",77 "python_include/genobject.h",78 "python_include/pymactoolbox.h",79 "python_include/compile.h",80 "python_include/pyexpat.h",81 "python_include/asdl.h",82 "python_include/codecs.h",83 "python_include/pyctype.h",84 "python_include/sysmodule.h",85 "python_include/methodobject.h",86 "python_include/graminit.h",87 "python_include/cobject.h",88 "python_include/intrcheck.h",89 "python_include/pyport.h",90 "python_include/warnings.h",91 "python_include/osdefs.h",92 "python_include/fileobject.h",93 "python_include/stringobject.h",94 "python_include/timefuncs.h",95 "python_include/traceback.h",96 "python_include/ceval.h",97 "python_include/bytes_methods.h",98 "python_include/pyconfig.h",99 "python_include/Python.h",100 "python_include/moduleobject.h",101 "python_include/pystate.h",102 "python_include/descrobject.h",103 "python_include/ucnhash.h",104 "python_include/pygetopt.h",105 "python_include/pymem.h",106 "python_include/complexobject.h",107 "python_include/structseq.h",108 "python_include/datetime.h",109 "python_include/pythonrun.h",110 "python_include/numpy/oldnumeric.h",111 "python_include/numpy/npy_1_7_deprecated_api.h",112 "python_include/numpy/ufunc_api.txt",113 "python_include/numpy/multiarray_api.txt",114 "python_include/numpy/halffloat.h",115 "python_include/numpy/npy_common.h",116 "python_include/numpy/utils.h",117 "python_include/numpy/npy_interrupt.h",118 "python_include/numpy/npy_endian.h",119 "python_include/numpy/__ufunc_api.h",120 "python_include/numpy/_neighborhood_iterator_imp.h",121 "python_include/numpy/ufuncobject.h",122 "python_include/numpy/ndarraytypes.h",123 "python_include/numpy/npy_math.h",124 "python_include/numpy/noprefix.h",125 "python_include/numpy/npy_3kcompat.h",126 "python_include/numpy/arrayscalars.h",127 "python_include/numpy/npy_os.h",128 "python_include/numpy/ndarrayobject.h",129 "python_include/numpy/npy_no_deprecated_api.h",130 "python_include/numpy/arrayobject.h",131 "python_include/numpy/_numpyconfig.h",132 "python_include/numpy/__multiarray_api.h",133 "python_include/numpy/npy_cpu.h",134 "python_include/numpy/old_defines.h",135 "python_include/numpy/numpyconfig.h",136 "python_include/pycapsule.h",137 "python_include/setobject.h",138 "python_include/listobject.h",139 "python_include/bytesobject.h",140 "python_include/pgen.h",141 "python_include/patchlevel.h",142 "python_include/opcode.h",143 "python_include/parsetok.h",144 "python_include/marshal.h",145 "python_include/token.h",146 "python_include/iterobject.h",147 "python_include/abstract.h",148 "python_include/py_curses.h",149 "python_include/metagrammar.h",150 "python_include/bufferobject.h",151 "python_include/Python-ast.h",152 ],153 cmd = """154cp "/usr/include/python2.7/code.h" "$(@D)/python_include/code.h" && cp "/usr/include/python2.7/dtoa.h" "$(@D)/python_include/dtoa.h" && cp "/usr/include/python2.7/tupleobject.h" "$(@D)/python_include/tupleobject.h" && cp "/usr/include/python2.7/object.h" "$(@D)/python_include/object.h" && cp "/usr/include/python2.7/ast.h" "$(@D)/python_include/ast.h" && cp "/usr/include/python2.7/pymacconfig.h" "$(@D)/python_include/pymacconfig.h" && cp "/usr/include/python2.7/errcode.h" "$(@D)/python_include/errcode.h" && cp "/usr/include/python2.7/frameobject.h" "$(@D)/python_include/frameobject.h" && cp "/usr/include/python2.7/pgenheaders.h" "$(@D)/python_include/pgenheaders.h" && cp "/usr/include/python2.7/cellobject.h" "$(@D)/python_include/cellobject.h" && cp "/usr/include/python2.7/intobject.h" "$(@D)/python_include/intobject.h" && cp "/usr/include/python2.7/pythread.h" "$(@D)/python_include/pythread.h" && cp "/usr/include/python2.7/cStringIO.h" "$(@D)/python_include/cStringIO.h" && cp "/usr/include/python2.7/boolobject.h" "$(@D)/python_include/boolobject.h" && cp "/usr/include/python2.7/modsupport.h" "$(@D)/python_include/modsupport.h" && cp "/usr/include/python2.7/import.h" "$(@D)/python_include/import.h" && cp "/usr/include/python2.7/pymath.h" "$(@D)/python_include/pymath.h" && cp "/usr/include/python2.7/node.h" "$(@D)/python_include/node.h" && cp "/usr/include/python2.7/funcobject.h" "$(@D)/python_include/funcobject.h" && cp "/usr/include/python2.7/eval.h" "$(@D)/python_include/eval.h" && cp "/usr/include/python2.7/longintrepr.h" "$(@D)/python_include/longintrepr.h" && cp "/usr/include/python2.7/floatobject.h" "$(@D)/python_include/floatobject.h" && cp "/usr/include/python2.7/rangeobject.h" "$(@D)/python_include/rangeobject.h" && cp "/usr/include/python2.7/pyfpe.h" "$(@D)/python_include/pyfpe.h" && cp "/usr/include/python2.7/pystrcmp.h" "$(@D)/python_include/pystrcmp.h" && cp "/usr/include/python2.7/dictobject.h" "$(@D)/python_include/dictobject.h" && cp "/usr/include/python2.7/pyarena.h" "$(@D)/python_include/pyarena.h" && cp "/usr/include/python2.7/objimpl.h" "$(@D)/python_include/objimpl.h" && cp "/usr/include/python2.7/bitset.h" "$(@D)/python_include/bitset.h" && cp "/usr/include/python2.7/memoryobject.h" "$(@D)/python_include/memoryobject.h" && cp "/usr/include/python2.7/bytearrayobject.h" "$(@D)/python_include/bytearrayobject.h" && cp "/usr/include/python2.7/pydebug.h" "$(@D)/python_include/pydebug.h" && cp "/usr/include/python2.7/pyerrors.h" "$(@D)/python_include/pyerrors.h" && cp "/usr/include/python2.7/weakrefobject.h" "$(@D)/python_include/weakrefobject.h" && cp "/usr/include/python2.7/grammar.h" "$(@D)/python_include/grammar.h" && cp "/usr/include/python2.7/symtable.h" "$(@D)/python_include/symtable.h" && cp "/usr/include/python2.7/longobject.h" "$(@D)/python_include/longobject.h" && cp "/usr/include/python2.7/structmember.h" "$(@D)/python_include/structmember.h" && cp "/usr/include/python2.7/enumobject.h" "$(@D)/python_include/enumobject.h" && cp "/usr/include/python2.7/classobject.h" "$(@D)/python_include/classobject.h" && cp "/usr/include/python2.7/unicodeobject.h" "$(@D)/python_include/unicodeobject.h" && cp "/usr/include/python2.7/sliceobject.h" "$(@D)/python_include/sliceobject.h" && cp "/usr/include/python2.7/pystrtod.h" "$(@D)/python_include/pystrtod.h" && cp "/usr/include/python2.7/genobject.h" "$(@D)/python_include/genobject.h" && cp "/usr/include/python2.7/pymactoolbox.h" "$(@D)/python_include/pymactoolbox.h" && cp "/usr/include/python2.7/compile.h" "$(@D)/python_include/compile.h" && cp "/usr/include/python2.7/pyexpat.h" "$(@D)/python_include/pyexpat.h" && cp "/usr/include/python2.7/asdl.h" "$(@D)/python_include/asdl.h" && cp "/usr/include/python2.7/codecs.h" "$(@D)/python_include/codecs.h" && cp "/usr/include/python2.7/pyctype.h" "$(@D)/python_include/pyctype.h" && cp "/usr/include/python2.7/sysmodule.h" "$(@D)/python_include/sysmodule.h" && cp "/usr/include/python2.7/methodobject.h" "$(@D)/python_include/methodobject.h" && cp "/usr/include/python2.7/graminit.h" "$(@D)/python_include/graminit.h" && cp "/usr/include/python2.7/cobject.h" "$(@D)/python_include/cobject.h" && cp "/usr/include/python2.7/intrcheck.h" "$(@D)/python_include/intrcheck.h" && cp "/usr/include/python2.7/pyport.h" "$(@D)/python_include/pyport.h" && cp "/usr/include/python2.7/warnings.h" "$(@D)/python_include/warnings.h" && cp "/usr/include/python2.7/osdefs.h" "$(@D)/python_include/osdefs.h" && cp "/usr/include/python2.7/fileobject.h" "$(@D)/python_include/fileobject.h" && cp "/usr/include/python2.7/stringobject.h" "$(@D)/python_include/stringobject.h" && cp "/usr/include/python2.7/timefuncs.h" "$(@D)/python_include/timefuncs.h" && cp "/usr/include/python2.7/traceback.h" "$(@D)/python_include/traceback.h" && cp "/usr/include/python2.7/ceval.h" "$(@D)/python_include/ceval.h" && cp "/usr/include/python2.7/bytes_methods.h" "$(@D)/python_include/bytes_methods.h" && cp "/usr/include/python2.7/pyconfig.h" "$(@D)/python_include/pyconfig.h" && cp "/usr/include/python2.7/Python.h" "$(@D)/python_include/Python.h" && cp "/usr/include/python2.7/moduleobject.h" "$(@D)/python_include/moduleobject.h" && cp "/usr/include/python2.7/pystate.h" "$(@D)/python_include/pystate.h" && cp "/usr/include/python2.7/descrobject.h" "$(@D)/python_include/descrobject.h" && cp "/usr/include/python2.7/ucnhash.h" "$(@D)/python_include/ucnhash.h" && cp "/usr/include/python2.7/pygetopt.h" "$(@D)/python_include/pygetopt.h" && cp "/usr/include/python2.7/pymem.h" "$(@D)/python_include/pymem.h" && cp "/usr/include/python2.7/complexobject.h" "$(@D)/python_include/complexobject.h" && cp "/usr/include/python2.7/structseq.h" "$(@D)/python_include/structseq.h" && cp "/usr/include/python2.7/datetime.h" "$(@D)/python_include/datetime.h" && cp "/usr/include/python2.7/pythonrun.h" "$(@D)/python_include/pythonrun.h" && cp "/usr/include/python2.7/numpy/oldnumeric.h" "$(@D)/python_include/numpy/oldnumeric.h" && cp "/usr/include/python2.7/numpy/npy_1_7_deprecated_api.h" "$(@D)/python_include/numpy/npy_1_7_deprecated_api.h" && cp "/usr/include/python2.7/numpy/ufunc_api.txt" "$(@D)/python_include/numpy/ufunc_api.txt" && cp "/usr/include/python2.7/numpy/multiarray_api.txt" "$(@D)/python_include/numpy/multiarray_api.txt" && cp "/usr/include/python2.7/numpy/halffloat.h" "$(@D)/python_include/numpy/halffloat.h" && cp "/usr/include/python2.7/numpy/npy_common.h" "$(@D)/python_include/numpy/npy_common.h" && cp "/usr/include/python2.7/numpy/utils.h" "$(@D)/python_include/numpy/utils.h" && cp "/usr/include/python2.7/numpy/npy_interrupt.h" "$(@D)/python_include/numpy/npy_interrupt.h" && cp "/usr/include/python2.7/numpy/npy_endian.h" "$(@D)/python_include/numpy/npy_endian.h" && cp "/usr/include/python2.7/numpy/__ufunc_api.h" "$(@D)/python_include/numpy/__ufunc_api.h" && cp "/usr/include/python2.7/numpy/_neighborhood_iterator_imp.h" "$(@D)/python_include/numpy/_neighborhood_iterator_imp.h" && cp "/usr/include/python2.7/numpy/ufuncobject.h" "$(@D)/python_include/numpy/ufuncobject.h" && cp "/usr/include/python2.7/numpy/ndarraytypes.h" "$(@D)/python_include/numpy/ndarraytypes.h" && cp "/usr/include/python2.7/numpy/npy_math.h" "$(@D)/python_include/numpy/npy_math.h" && cp "/usr/include/python2.7/numpy/noprefix.h" "$(@D)/python_include/numpy/noprefix.h" && cp "/usr/include/python2.7/numpy/npy_3kcompat.h" "$(@D)/python_include/numpy/npy_3kcompat.h" && cp "/usr/include/python2.7/numpy/arrayscalars.h" "$(@D)/python_include/numpy/arrayscalars.h" && cp "/usr/include/python2.7/numpy/npy_os.h" "$(@D)/python_include/numpy/npy_os.h" && cp "/usr/include/python2.7/numpy/ndarrayobject.h" "$(@D)/python_include/numpy/ndarrayobject.h" && cp "/usr/include/python2.7/numpy/npy_no_deprecated_api.h" "$(@D)/python_include/numpy/npy_no_deprecated_api.h" && cp "/usr/include/python2.7/numpy/arrayobject.h" "$(@D)/python_include/numpy/arrayobject.h" && cp "/usr/include/python2.7/numpy/_numpyconfig.h" "$(@D)/python_include/numpy/_numpyconfig.h" && cp "/usr/include/python2.7/numpy/__multiarray_api.h" "$(@D)/python_include/numpy/__multiarray_api.h" && cp "/usr/include/python2.7/numpy/npy_cpu.h" "$(@D)/python_include/numpy/npy_cpu.h" && cp "/usr/include/python2.7/numpy/old_defines.h" "$(@D)/python_include/numpy/old_defines.h" && cp "/usr/include/python2.7/numpy/numpyconfig.h" "$(@D)/python_include/numpy/numpyconfig.h" && cp "/usr/include/python2.7/pycapsule.h" "$(@D)/python_include/pycapsule.h" && cp "/usr/include/python2.7/setobject.h" "$(@D)/python_include/setobject.h" && cp "/usr/include/python2.7/listobject.h" "$(@D)/python_include/listobject.h" && cp "/usr/include/python2.7/bytesobject.h" "$(@D)/python_include/bytesobject.h" && cp "/usr/include/python2.7/pgen.h" "$(@D)/python_include/pgen.h" && cp "/usr/include/python2.7/patchlevel.h" "$(@D)/python_include/patchlevel.h" && cp "/usr/include/python2.7/opcode.h" "$(@D)/python_include/opcode.h" && cp "/usr/include/python2.7/parsetok.h" "$(@D)/python_include/parsetok.h" && cp "/usr/include/python2.7/marshal.h" "$(@D)/python_include/marshal.h" && cp "/usr/include/python2.7/token.h" "$(@D)/python_include/token.h" && cp "/usr/include/python2.7/iterobject.h" "$(@D)/python_include/iterobject.h" && cp "/usr/include/python2.7/abstract.h" "$(@D)/python_include/abstract.h" && cp "/usr/include/python2.7/py_curses.h" "$(@D)/python_include/py_curses.h" && cp "/usr/include/python2.7/metagrammar.h" "$(@D)/python_include/metagrammar.h" && cp "/usr/include/python2.7/bufferobject.h" "$(@D)/python_include/bufferobject.h" && cp "/usr/include/python2.7/Python-ast.h" "$(@D)/python_include/Python-ast.h"155 """,156)157genrule(158 name = "numpy_include",159 outs = [160 "numpy_include/numpy/oldnumeric.h",161 "numpy_include/numpy/npy_1_7_deprecated_api.h",162 "numpy_include/numpy/ufunc_api.txt",163 "numpy_include/numpy/multiarray_api.txt",164 "numpy_include/numpy/halffloat.h",165 "numpy_include/numpy/npy_common.h",166 "numpy_include/numpy/utils.h",167 "numpy_include/numpy/npy_interrupt.h",168 "numpy_include/numpy/npy_endian.h",169 "numpy_include/numpy/__ufunc_api.h",170 "numpy_include/numpy/_neighborhood_iterator_imp.h",171 "numpy_include/numpy/ufuncobject.h",172 "numpy_include/numpy/ndarraytypes.h",173 "numpy_include/numpy/npy_math.h",174 "numpy_include/numpy/noprefix.h",175 "numpy_include/numpy/npy_3kcompat.h",176 "numpy_include/numpy/arrayscalars.h",177 "numpy_include/numpy/npy_os.h",178 "numpy_include/numpy/ndarrayobject.h",179 "numpy_include/numpy/npy_no_deprecated_api.h",180 "numpy_include/numpy/arrayobject.h",181 "numpy_include/numpy/_numpyconfig.h",182 "numpy_include/numpy/__multiarray_api.h",183 "numpy_include/numpy/npy_cpu.h",184 "numpy_include/numpy/old_defines.h",185 "numpy_include/numpy/numpyconfig.h",186 ],187 cmd = """188cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/oldnumeric.h" "$(@D)/numpy_include/numpy/oldnumeric.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h" "$(@D)/numpy_include/numpy/npy_1_7_deprecated_api.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufunc_api.txt" "$(@D)/numpy_include/numpy/ufunc_api.txt" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/multiarray_api.txt" "$(@D)/numpy_include/numpy/multiarray_api.txt" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/halffloat.h" "$(@D)/numpy_include/numpy/halffloat.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_common.h" "$(@D)/numpy_include/numpy/npy_common.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/utils.h" "$(@D)/numpy_include/numpy/utils.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_interrupt.h" "$(@D)/numpy_include/numpy/npy_interrupt.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_endian.h" "$(@D)/numpy_include/numpy/npy_endian.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__ufunc_api.h" "$(@D)/numpy_include/numpy/__ufunc_api.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/_neighborhood_iterator_imp.h" "$(@D)/numpy_include/numpy/_neighborhood_iterator_imp.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufuncobject.h" "$(@D)/numpy_include/numpy/ufuncobject.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h" "$(@D)/numpy_include/numpy/ndarraytypes.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_math.h" "$(@D)/numpy_include/numpy/npy_math.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/noprefix.h" "$(@D)/numpy_include/numpy/noprefix.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_3kcompat.h" "$(@D)/numpy_include/numpy/npy_3kcompat.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayscalars.h" "$(@D)/numpy_include/numpy/arrayscalars.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_os.h" "$(@D)/numpy_include/numpy/npy_os.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h" "$(@D)/numpy_include/numpy/ndarrayobject.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_no_deprecated_api.h" "$(@D)/numpy_include/numpy/npy_no_deprecated_api.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h" "$(@D)/numpy_include/numpy/arrayobject.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/_numpyconfig.h" "$(@D)/numpy_include/numpy/_numpyconfig.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__multiarray_api.h" "$(@D)/numpy_include/numpy/__multiarray_api.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_cpu.h" "$(@D)/numpy_include/numpy/npy_cpu.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/old_defines.h" "$(@D)/numpy_include/numpy/old_defines.h" && cp "/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/numpyconfig.h" "$(@D)/numpy_include/numpy/numpyconfig.h"189 """,...

Full Screen

Full Screen

AmpCustomElement.js

Source:AmpCustomElement.js Github

copy

Full Screen

1/**2 * @file An AMP Component import helper. This file is auto-generated using3 * https://www.npmjs.com/package/@ampproject/toolbox-validator-rules.4 */5import React from 'react'6import Head from 'next/head'7export function AmpIncludeCustomElement(props) {8 return (9 <Head>10 <script11 async12 custom-element={props.name}13 src={14 'https://cdn.ampproject.org/v0/' +15 props.name +16 '-' +17 props.version +18 '.js'19 }20 key={props.name}21 />22 </Head>23 )24}25export function AmpIncludeCustomTemplate(props) {26 return (27 <Head>28 <script29 async30 custom-template={props.name}31 src={32 'https://cdn.ampproject.org/v0/' +33 props.name +34 '-' +35 props.version +36 '.js'37 }38 key={props.name}39 />40 </Head>41 )42}43export function AmpIncludeAmp3dGltf() {44 return <AmpIncludeCustomElement name="amp-3d-gltf" version="0.1" />45}46export function AmpIncludeAmp3qPlayer() {47 return <AmpIncludeCustomElement name="amp-3q-player" version="0.1" />48}49export function AmpIncludeAmpAccessLaterpay() {50 return <AmpIncludeCustomElement name="amp-access-laterpay" version="0.2" />51}52export function AmpIncludeAmpAccessPoool() {53 return <AmpIncludeCustomElement name="amp-access-poool" version="0.1" />54}55export function AmpIncludeAmpAccessScroll() {56 return <AmpIncludeCustomElement name="amp-access-scroll" version="0.1" />57}58export function AmpIncludeAmpAccess() {59 return <AmpIncludeCustomElement name="amp-access" version="0.1" />60}61export function AmpIncludeAmpAccordion() {62 return <AmpIncludeCustomElement name="amp-accordion" version="0.1" />63}64export function AmpIncludeAmpActionMacro() {65 return <AmpIncludeCustomElement name="amp-action-macro" version="0.1" />66}67export function AmpIncludeAmpAdCustom() {68 return <AmpIncludeCustomElement name="amp-ad-custom" version="0.1" />69}70export function AmpIncludeAmpAd() {71 return <AmpIncludeCustomElement name="amp-ad" version="0.1" />72}73export function AmpIncludeAmpAddthis() {74 return <AmpIncludeCustomElement name="amp-addthis" version="0.1" />75}76export function AmpIncludeAmpAnalytics() {77 return <AmpIncludeCustomElement name="amp-analytics" version="0.1" />78}79export function AmpIncludeAmpAnim() {80 return <AmpIncludeCustomElement name="amp-anim" version="0.1" />81}82export function AmpIncludeAmpAnimation() {83 return <AmpIncludeCustomElement name="amp-animation" version="0.1" />84}85export function AmpIncludeAmpApesterMedia() {86 return <AmpIncludeCustomElement name="amp-apester-media" version="0.1" />87}88export function AmpIncludeAmpAppBanner() {89 return <AmpIncludeCustomElement name="amp-app-banner" version="0.1" />90}91export function AmpIncludeAmpAudio() {92 return <AmpIncludeCustomElement name="amp-audio" version="0.1" />93}94export function AmpIncludeAmpAutoAds() {95 return <AmpIncludeCustomElement name="amp-auto-ads" version="0.1" />96}97export function AmpIncludeAmpAutocomplete() {98 return <AmpIncludeCustomElement name="amp-autocomplete" version="0.1" />99}100export function AmpIncludeAmpBaseCarousel() {101 return <AmpIncludeCustomElement name="amp-base-carousel" version="0.1" />102}103export function AmpIncludeAmpBeopinion() {104 return <AmpIncludeCustomElement name="amp-beopinion" version="0.1" />105}106export function AmpIncludeAmpBind() {107 return <AmpIncludeCustomElement name="amp-bind" version="0.1" />108}109export function AmpIncludeAmpBodymovinAnimation() {110 return (111 <AmpIncludeCustomElement name="amp-bodymovin-animation" version="0.1" />112 )113}114export function AmpIncludeAmpBridPlayer() {115 return <AmpIncludeCustomElement name="amp-brid-player" version="0.1" />116}117export function AmpIncludeAmpBrightcove() {118 return <AmpIncludeCustomElement name="amp-brightcove" version="0.1" />119}120export function AmpIncludeAmpBysideContent() {121 return <AmpIncludeCustomElement name="amp-byside-content" version="0.1" />122}123export function AmpIncludeAmpCallTracking() {124 return <AmpIncludeCustomElement name="amp-call-tracking" version="0.1" />125}126export function AmpIncludeAmpCarousel() {127 return <AmpIncludeCustomElement name="amp-carousel" version="0.2" />128}129export function AmpIncludeAmpConnatixPlayer() {130 return <AmpIncludeCustomElement name="amp-connatix-player" version="0.1" />131}132export function AmpIncludeAmpConsent() {133 return <AmpIncludeCustomElement name="amp-consent" version="0.1" />134}135export function AmpIncludeAmpDailymotion() {136 return <AmpIncludeCustomElement name="amp-dailymotion" version="0.1" />137}138export function AmpIncludeAmpDateCountdown() {139 return <AmpIncludeCustomElement name="amp-date-countdown" version="0.1" />140}141export function AmpIncludeAmpDateDisplay() {142 return <AmpIncludeCustomElement name="amp-date-display" version="0.1" />143}144export function AmpIncludeAmpDatePicker() {145 return <AmpIncludeCustomElement name="amp-date-picker" version="0.1" />146}147export function AmpIncludeAmpDelightPlayer() {148 return <AmpIncludeCustomElement name="amp-delight-player" version="0.1" />149}150export function AmpIncludeAmpDynamicCssClasses() {151 return (152 <AmpIncludeCustomElement name="amp-dynamic-css-classes" version="0.1" />153 )154}155export function AmpIncludeAmpEmbedlyCard() {156 return <AmpIncludeCustomElement name="amp-embedly-card" version="0.1" />157}158export function AmpIncludeAmpExperiment() {159 return <AmpIncludeCustomElement name="amp-experiment" version="1.0" />160}161export function AmpIncludeAmpFacebookComments() {162 return <AmpIncludeCustomElement name="amp-facebook-comments" version="0.1" />163}164export function AmpIncludeAmpFacebookLike() {165 return <AmpIncludeCustomElement name="amp-facebook-like" version="0.1" />166}167export function AmpIncludeAmpFacebookPage() {168 return <AmpIncludeCustomElement name="amp-facebook-page" version="0.1" />169}170export function AmpIncludeAmpFacebook() {171 return <AmpIncludeCustomElement name="amp-facebook" version="0.1" />172}173export function AmpIncludeAmpFitText() {174 return <AmpIncludeCustomElement name="amp-fit-text" version="0.1" />175}176export function AmpIncludeAmpFont() {177 return <AmpIncludeCustomElement name="amp-font" version="0.1" />178}179export function AmpIncludeAmpForm() {180 return <AmpIncludeCustomElement name="amp-form" version="0.1" />181}182export function AmpIncludeAmpFxCollection() {183 return <AmpIncludeCustomElement name="amp-fx-collection" version="0.1" />184}185export function AmpIncludeAmpFxFlyingCarpet() {186 return <AmpIncludeCustomElement name="amp-fx-flying-carpet" version="0.1" />187}188export function AmpIncludeAmpGeo() {189 return <AmpIncludeCustomElement name="amp-geo" version="0.1" />190}191export function AmpIncludeAmpGfycat() {192 return <AmpIncludeCustomElement name="amp-gfycat" version="0.1" />193}194export function AmpIncludeAmpGist() {195 return <AmpIncludeCustomElement name="amp-gist" version="0.1" />196}197export function AmpIncludeAmpGoogleDocumentEmbed() {198 return (199 <AmpIncludeCustomElement name="amp-google-document-embed" version="0.1" />200 )201}202export function AmpIncludeAmpHulu() {203 return <AmpIncludeCustomElement name="amp-hulu" version="0.1" />204}205export function AmpIncludeAmpIframe() {206 return <AmpIncludeCustomElement name="amp-iframe" version="0.1" />207}208export function AmpIncludeAmpImaVideo() {209 return <AmpIncludeCustomElement name="amp-ima-video" version="0.1" />210}211export function AmpIncludeAmpImageLightbox() {212 return <AmpIncludeCustomElement name="amp-image-lightbox" version="0.1" />213}214export function AmpIncludeAmpImageSlider() {215 return <AmpIncludeCustomElement name="amp-image-slider" version="0.1" />216}217export function AmpIncludeAmpImgur() {218 return <AmpIncludeCustomElement name="amp-imgur" version="0.1" />219}220export function AmpIncludeAmpInputmask() {221 return <AmpIncludeCustomElement name="amp-inputmask" version="0.1" />222}223export function AmpIncludeAmpInstagram() {224 return <AmpIncludeCustomElement name="amp-instagram" version="0.1" />225}226export function AmpIncludeAmpInstallServiceworker() {227 return (228 <AmpIncludeCustomElement name="amp-install-serviceworker" version="0.1" />229 )230}231export function AmpIncludeAmpIzlesene() {232 return <AmpIncludeCustomElement name="amp-izlesene" version="0.1" />233}234export function AmpIncludeAmpJwplayer() {235 return <AmpIncludeCustomElement name="amp-jwplayer" version="0.1" />236}237export function AmpIncludeAmpKalturaPlayer() {238 return <AmpIncludeCustomElement name="amp-kaltura-player" version="0.1" />239}240export function AmpIncludeAmpLightboxGallery() {241 return <AmpIncludeCustomElement name="amp-lightbox-gallery" version="0.1" />242}243export function AmpIncludeAmpLightbox() {244 return <AmpIncludeCustomElement name="amp-lightbox" version="0.1" />245}246export function AmpIncludeAmpLinkRewriter() {247 return <AmpIncludeCustomElement name="amp-link-rewriter" version="0.1" />248}249export function AmpIncludeAmpList() {250 return (251 <>252 <AmpIncludeAmpMustache />253 <AmpIncludeCustomElement name="amp-list" version="0.1" />254 </>255 )256}257export function AmpIncludeAmpLiveList() {258 return <AmpIncludeCustomElement name="amp-live-list" version="0.1" />259}260export function AmpIncludeAmpMathml() {261 return <AmpIncludeCustomElement name="amp-mathml" version="0.1" />262}263export function AmpIncludeAmpMegaphone() {264 return <AmpIncludeCustomElement name="amp-megaphone" version="0.1" />265}266export function AmpIncludeAmpMinuteMediaPlayer() {267 return (268 <AmpIncludeCustomElement name="amp-minute-media-player" version="0.1" />269 )270}271export function AmpIncludeAmpMowplayer() {272 return <AmpIncludeCustomElement name="amp-mowplayer" version="0.1" />273}274export function AmpIncludeAmpMustache() {275 return <AmpIncludeCustomTemplate name="amp-mustache" version="0.2" />276}277export function AmpIncludeAmpNextPage() {278 return <AmpIncludeCustomElement name="amp-next-page" version="0.1" />279}280export function AmpIncludeAmpNexxtvPlayer() {281 return <AmpIncludeCustomElement name="amp-nexxtv-player" version="0.1" />282}283export function AmpIncludeAmpO2Player() {284 return <AmpIncludeCustomElement name="amp-o2-player" version="0.1" />285}286export function AmpIncludeAmpOoyalaPlayer() {287 return <AmpIncludeCustomElement name="amp-ooyala-player" version="0.1" />288}289export function AmpIncludeAmpOrientationObserver() {290 return (291 <AmpIncludeCustomElement name="amp-orientation-observer" version="0.1" />292 )293}294export function AmpIncludeAmpPanZoom() {295 return <AmpIncludeCustomElement name="amp-pan-zoom" version="0.1" />296}297export function AmpIncludeAmpPinterest() {298 return <AmpIncludeCustomElement name="amp-pinterest" version="0.1" />299}300export function AmpIncludeAmpPlaybuzz() {301 return <AmpIncludeCustomElement name="amp-playbuzz" version="0.1" />302}303export function AmpIncludeAmpPositionObserver() {304 return <AmpIncludeCustomElement name="amp-position-observer" version="0.1" />305}306export function AmpIncludeAmpPowrPlayer() {307 return <AmpIncludeCustomElement name="amp-powr-player" version="0.1" />308}309export function AmpIncludeAmpReachPlayer() {310 return <AmpIncludeCustomElement name="amp-reach-player" version="0.1" />311}312export function AmpIncludeAmpRecaptchaInput() {313 return <AmpIncludeCustomElement name="amp-recaptcha-input" version="0.1" />314}315export function AmpIncludeAmpReddit() {316 return <AmpIncludeCustomElement name="amp-reddit" version="0.1" />317}318export function AmpIncludeAmpRiddleQuiz() {319 return <AmpIncludeCustomElement name="amp-riddle-quiz" version="0.1" />320}321export function AmpIncludeAmpScript() {322 return <AmpIncludeCustomElement name="amp-script" version="0.1" />323}324export function AmpIncludeAmpSelector() {325 return <AmpIncludeCustomElement name="amp-selector" version="0.1" />326}327export function AmpIncludeAmpSidebar() {328 return <AmpIncludeCustomElement name="amp-sidebar" version="0.1" />329}330export function AmpIncludeAmpSkimlinks() {331 return <AmpIncludeCustomElement name="amp-skimlinks" version="0.1" />332}333export function AmpIncludeAmpSlides() {334 return <AmpIncludeCustomElement name="amp-slides" version="0.1" />335}336export function AmpIncludeAmpSmartlinks() {337 return <AmpIncludeCustomElement name="amp-smartlinks" version="0.1" />338}339export function AmpIncludeAmpSocialShare() {340 return <AmpIncludeCustomElement name="amp-social-share" version="0.1" />341}342export function AmpIncludeAmpSoundcloud() {343 return <AmpIncludeCustomElement name="amp-soundcloud" version="0.1" />344}345export function AmpIncludeAmpSpringboardPlayer() {346 return <AmpIncludeCustomElement name="amp-springboard-player" version="0.1" />347}348export function AmpIncludeAmpStickyAd() {349 return <AmpIncludeCustomElement name="amp-sticky-ad" version="1.0" />350}351export function AmpIncludeAmpStoryAutoAds() {352 return <AmpIncludeCustomElement name="amp-story-auto-ads" version="0.1" />353}354export function AmpIncludeAmpStory() {355 return <AmpIncludeCustomElement name="amp-story" version="1.0" />356}357export function AmpIncludeAmpSubscriptions() {358 return <AmpIncludeCustomElement name="amp-subscriptions" version="0.1" />359}360export function AmpIncludeAmpSubscriptionsGoogle() {361 return (362 <AmpIncludeCustomElement name="amp-subscriptions-google" version="0.1" />363 )364}365export function AmpIncludeAmpTimeago() {366 return <AmpIncludeCustomElement name="amp-timeago" version="0.1" />367}368export function AmpIncludeAmpTruncateText() {369 return <AmpIncludeCustomElement name="amp-truncate-text" version="0.1" />370}371export function AmpIncludeAmpTwitter() {372 return <AmpIncludeCustomElement name="amp-twitter" version="0.1" />373}374export function AmpIncludeAmpUserLocation() {375 return <AmpIncludeCustomElement name="amp-user-location" version="0.1" />376}377export function AmpIncludeAmpUserNotification() {378 return <AmpIncludeCustomElement name="amp-user-notification" version="0.1" />379}380export function AmpIncludeAmpVideoDocking() {381 return <AmpIncludeCustomElement name="amp-video-docking" version="0.1" />382}383export function AmpIncludeAmpVideoIframe() {384 return <AmpIncludeCustomElement name="amp-video-iframe" version="0.1" />385}386export function AmpIncludeAmpVideo() {387 return <AmpIncludeCustomElement name="amp-video" version="0.1" />388}389export function AmpIncludeAmpVimeo() {390 return <AmpIncludeCustomElement name="amp-vimeo" version="0.1" />391}392export function AmpIncludeAmpVine() {393 return <AmpIncludeCustomElement name="amp-vine" version="0.1" />394}395export function AmpIncludeAmpViqeoPlayer() {396 return <AmpIncludeCustomElement name="amp-viqeo-player" version="0.1" />397}398export function AmpIncludeAmpVk() {399 return <AmpIncludeCustomElement name="amp-vk" version="0.1" />400}401export function AmpIncludeAmpWebPush() {402 return <AmpIncludeCustomElement name="amp-web-push" version="0.1" />403}404export function AmpIncludeAmpWistiaPlayer() {405 return <AmpIncludeCustomElement name="amp-wistia-player" version="0.1" />406}407export function AmpIncludeAmpYotpo() {408 return <AmpIncludeCustomElement name="amp-yotpo" version="0.1" />409}410export function AmpIncludeAmpYoutube() {411 return <AmpIncludeCustomElement name="amp-youtube" version="0.1" />...

Full Screen

Full Screen

test_include.py

Source:test_include.py Github

copy

Full Screen

1from django.template import (2 Context, Template, TemplateDoesNotExist, TemplateSyntaxError, engines,3)4from django.test import SimpleTestCase, override_settings5from ..utils import setup6from .test_basic import basic_templates7include_fail_templates = {8 'include-fail1': '{% load bad_tag %}{% badtag %}',9 'include-fail2': '{% load broken_tag %}',10}11class IncludeTagTests(SimpleTestCase):12 @setup({'include01': '{% include "basic-syntax01" %}'}, basic_templates)13 def test_include01(self):14 output = self.engine.render_to_string('include01')15 self.assertEqual(output, 'something cool')16 @setup({'include02': '{% include "basic-syntax02" %}'}, basic_templates)17 def test_include02(self):18 output = self.engine.render_to_string('include02', {'headline': 'Included'})19 self.assertEqual(output, 'Included')20 @setup({'include03': '{% include template_name %}'}, basic_templates)21 def test_include03(self):22 output = self.engine.render_to_string(23 'include03',24 {'template_name': 'basic-syntax02', 'headline': 'Included'},25 )26 self.assertEqual(output, 'Included')27 @setup({'include04': 'a{% include "nonexistent" %}b'})28 def test_include04(self):29 template = self.engine.get_template('include04')30 if self.engine.debug:31 with self.assertRaises(TemplateDoesNotExist):32 template.render(Context({}))33 else:34 output = template.render(Context({}))35 self.assertEqual(output, "ab")36 @setup({37 'include 05': 'template with a space',38 'include06': '{% include "include 05"%}',39 })40 def test_include06(self):41 output = self.engine.render_to_string('include06')42 self.assertEqual(output, "template with a space")43 @setup({'include07': '{% include "basic-syntax02" with headline="Inline" %}'}, basic_templates)44 def test_include07(self):45 output = self.engine.render_to_string('include07', {'headline': 'Included'})46 self.assertEqual(output, 'Inline')47 @setup({'include08': '{% include headline with headline="Dynamic" %}'}, basic_templates)48 def test_include08(self):49 output = self.engine.render_to_string('include08', {'headline': 'basic-syntax02'})50 self.assertEqual(output, 'Dynamic')51 @setup(52 {'include09': '{{ first }}--'53 '{% include "basic-syntax03" with first=second|lower|upper second=first|upper %}'54 '--{{ second }}'},55 basic_templates,56 )57 def test_include09(self):58 output = self.engine.render_to_string('include09', {'first': 'Ul', 'second': 'lU'})59 self.assertEqual(output, 'Ul--LU --- UL--lU')60 @setup({'include10': '{% include "basic-syntax03" only %}'}, basic_templates)61 def test_include10(self):62 output = self.engine.render_to_string('include10', {'first': '1'})63 if self.engine.string_if_invalid:64 self.assertEqual(output, 'INVALID --- INVALID')65 else:66 self.assertEqual(output, ' --- ')67 @setup({'include11': '{% include "basic-syntax03" only with second=2 %}'}, basic_templates)68 def test_include11(self):69 output = self.engine.render_to_string('include11', {'first': '1'})70 if self.engine.string_if_invalid:71 self.assertEqual(output, 'INVALID --- 2')72 else:73 self.assertEqual(output, ' --- 2')74 @setup({'include12': '{% include "basic-syntax03" with first=1 only %}'}, basic_templates)75 def test_include12(self):76 output = self.engine.render_to_string('include12', {'second': '2'})77 if self.engine.string_if_invalid:78 self.assertEqual(output, '1 --- INVALID')79 else:80 self.assertEqual(output, '1 --- ')81 @setup(82 {'include13': '{% autoescape off %}{% include "basic-syntax03" %}{% endautoescape %}'},83 basic_templates,84 )85 def test_include13(self):86 output = self.engine.render_to_string('include13', {'first': '&'})87 if self.engine.string_if_invalid:88 self.assertEqual(output, '& --- INVALID')89 else:90 self.assertEqual(output, '& --- ')91 @setup(92 {'include14': '{% autoescape off %}'93 '{% include "basic-syntax03" with first=var1 only %}'94 '{% endautoescape %}'},95 basic_templates,96 )97 def test_include14(self):98 output = self.engine.render_to_string('include14', {'var1': '&'})99 if self.engine.string_if_invalid:100 self.assertEqual(output, '& --- INVALID')101 else:102 self.assertEqual(output, '& --- ')103 # Include syntax errors104 @setup({'include-error01': '{% include "basic-syntax01" with %}'})105 def test_include_error01(self):106 with self.assertRaises(TemplateSyntaxError):107 self.engine.get_template('include-error01')108 @setup({'include-error02': '{% include "basic-syntax01" with "no key" %}'})109 def test_include_error02(self):110 with self.assertRaises(TemplateSyntaxError):111 self.engine.get_template('include-error02')112 @setup({'include-error03': '{% include "basic-syntax01" with dotted.arg="error" %}'})113 def test_include_error03(self):114 with self.assertRaises(TemplateSyntaxError):115 self.engine.get_template('include-error03')116 @setup({'include-error04': '{% include "basic-syntax01" something_random %}'})117 def test_include_error04(self):118 with self.assertRaises(TemplateSyntaxError):119 self.engine.get_template('include-error04')120 @setup({'include-error05': '{% include "basic-syntax01" foo="duplicate" foo="key" %}'})121 def test_include_error05(self):122 with self.assertRaises(TemplateSyntaxError):123 self.engine.get_template('include-error05')124 @setup({'include-error06': '{% include "basic-syntax01" only only %}'})125 def test_include_error06(self):126 with self.assertRaises(TemplateSyntaxError):127 self.engine.get_template('include-error06')128 @setup(include_fail_templates)129 def test_include_fail1(self):130 with self.assertRaises(RuntimeError):131 self.engine.get_template('include-fail1')132 @setup(include_fail_templates)133 def test_include_fail2(self):134 with self.assertRaises(TemplateSyntaxError):135 self.engine.get_template('include-fail2')136 @setup({'include-error07': '{% include "include-fail1" %}'}, include_fail_templates)137 def test_include_error07(self):138 template = self.engine.get_template('include-error07')139 if self.engine.debug:140 with self.assertRaises(RuntimeError):141 template.render(Context())142 else:143 self.assertEqual(template.render(Context()), '')144 @setup({'include-error08': '{% include "include-fail2" %}'}, include_fail_templates)145 def test_include_error08(self):146 template = self.engine.get_template('include-error08')147 if self.engine.debug:148 with self.assertRaises(TemplateSyntaxError):149 template.render(Context())150 else:151 self.assertEqual(template.render(Context()), '')152 @setup({'include-error09': '{% include failed_include %}'}, include_fail_templates)153 def test_include_error09(self):154 context = Context({'failed_include': 'include-fail1'})155 template = self.engine.get_template('include-error09')156 if self.engine.debug:157 with self.assertRaises(RuntimeError):158 template.render(context)159 else:160 self.assertEqual(template.render(context), '')161 @setup({'include-error10': '{% include failed_include %}'}, include_fail_templates)162 def test_include_error10(self):163 context = Context({'failed_include': 'include-fail2'})164 template = self.engine.get_template('include-error10')165 if self.engine.debug:166 with self.assertRaises(TemplateSyntaxError):167 template.render(context)168 else:169 self.assertEqual(template.render(context), '')170class IncludeTests(SimpleTestCase):171 # Test the base loader class via the app loader. load_template172 # from base is used by all shipped loaders excepting cached,173 # which has its own test.174 @override_settings(TEMPLATES=[{175 'BACKEND': 'django.template.backends.django.DjangoTemplates',176 'APP_DIRS': True,177 'OPTIONS': {178 # Enable debug, otherwise the exception raised during179 # {% include %} processing will be suppressed.180 'debug': True,181 }182 }])183 def test_include_missing_template(self):184 """185 Tests that the correct template is identified as not existing186 when {% include %} specifies a template that does not exist.187 """188 template = engines['django'].get_template('test_include_error.html')189 with self.assertRaises(TemplateDoesNotExist) as e:190 template.render()191 self.assertEqual(e.exception.args[0], 'missing.html')192 # Test the base loader class via the app loader. load_template193 # from base is used by all shipped loaders excepting cached,194 # which has its own test.195 @override_settings(TEMPLATES=[{196 'BACKEND': 'django.template.backends.django.DjangoTemplates',197 'APP_DIRS': True,198 'OPTIONS': {199 # Enable debug, otherwise the exception raised during200 # {% include %} processing will be suppressed.201 'debug': True,202 }203 }])204 def test_extends_include_missing_baseloader(self):205 """206 #12787 -- Tests that the correct template is identified as not existing207 when {% extends %} specifies a template that does exist, but that208 template has an {% include %} of something that does not exist.209 """210 template = engines['django'].get_template('test_extends_error.html')211 with self.assertRaises(TemplateDoesNotExist) as e:212 template.render()213 self.assertEqual(e.exception.args[0], 'missing.html')214 @override_settings(TEMPLATES=[{215 'BACKEND': 'django.template.backends.django.DjangoTemplates',216 'OPTIONS': {217 'debug': True,218 'loaders': [219 ('django.template.loaders.cached.Loader', [220 'django.template.loaders.app_directories.Loader',221 ]),222 ],223 },224 }])225 def test_extends_include_missing_cachedloader(self):226 """227 Test the cache loader separately since it overrides load_template.228 """229 template = engines['django'].get_template('test_extends_error.html')230 with self.assertRaises(TemplateDoesNotExist) as e:231 template.render()232 self.assertEqual(e.exception.args[0], 'missing.html')233 # Repeat to ensure it still works when loading from the cache234 template = engines['django'].get_template('test_extends_error.html')235 with self.assertRaises(TemplateDoesNotExist) as e:236 template.render()237 self.assertEqual(e.exception.args[0], 'missing.html')238 def test_include_template_argument(self):239 """240 Support any render() supporting object241 """242 ctx = Context({243 'tmpl': Template('This worked!'),244 })245 outer_tmpl = Template('{% include tmpl %}')246 output = outer_tmpl.render(ctx)247 self.assertEqual(output, 'This worked!')248 @override_settings(TEMPLATES=[{249 'BACKEND': 'django.template.backends.django.DjangoTemplates',250 'OPTIONS': {251 'debug': True,252 },253 }])254 def test_include_immediate_missing(self):255 """256 #16417 -- Include tags pointing to missing templates should not raise257 an error at parsing time.258 """259 template = Template('{% include "this_does_not_exist.html" %}')260 self.assertIsInstance(template, Template)261 @override_settings(TEMPLATES=[{262 'BACKEND': 'django.template.backends.django.DjangoTemplates',263 'APP_DIRS': True,264 'OPTIONS': {265 'debug': True,266 },267 }])268 def test_include_recursive(self):269 comments = [270 {271 'comment': 'A1',272 'children': [273 {'comment': 'B1', 'children': []},274 {'comment': 'B2', 'children': []},275 {'comment': 'B3', 'children': [276 {'comment': 'C1', 'children': []}277 ]},278 ]279 }280 ]281 t = engines['django'].get_template('recursive_include.html')282 self.assertEqual(283 "Recursion! A1 Recursion! B1 B2 B3 Recursion! C1",284 t.render({'comments': comments}).replace(' ', '').replace('\n', ' ').strip(),...

Full Screen

Full Screen

formatter_test.py

Source:formatter_test.py Github

copy

Full Screen

1import unittest2from drake.tools.lint.formatter import FormatterBase, IncludeFormatter3class TestFormatterBase(unittest.TestCase):4 def test_essentials(self):5 original_lines = [6 '// Line 1\n',7 '/* Line 2 */\n',8 '\n',9 ]10 dut = FormatterBase('filename.cc', readlines=original_lines)11 # Everything starts out unchanged.12 self.assertTrue(dut.is_same_as_original())13 self.assertTrue(dut.is_permutation_of_original())14 self.assertEqual(dut.get_all_lines(), original_lines)15 self.assertTrue(dut.get_first_differing_original_index() is None)16 # Basic getters.17 self.assertEqual(dut.get_num_lines(), 3)18 self.assertTrue(dut.is_blank_line(2))19 self.assertEqual(dut.get_line(0), '// Line 1\n')20 # Reverse it and end up with a permutation.21 dut.set_all_lines(reversed(dut.get_all_lines()))22 self.assertFalse(dut.is_same_as_original())23 self.assertTrue(dut.is_permutation_of_original())24 self.assertEqual(dut.get_first_differing_original_index(), 0)25 # Rebuild it using insertion and removal.26 dut.set_all_lines(['\n'] * 3)27 dut.set_line(0, '/* Line 2 */\n')28 dut.insert_lines(0, ['AAA\n', '// Line 1\n'])29 dut.remove_all([0, 3])30 self.assertEqual(dut.get_all_lines(), original_lines)31 def test_format_ranges(self):32 original_lines = [33 '#include "line0"\n',34 '// clang-format off\n',35 '#include "line2"\n',36 '// clang-format on\n',37 '#include "line4"\n',38 '#include "line5"\n',39 '/* clang-format off */\n',40 '#include "line7"\n',41 '#include "line8"\n',42 '/* clang-format on */\n',43 '#include "line10"\n',44 ]45 dut = FormatterBase("filename.cc", readlines=original_lines)46 self.assertEqual(47 dut.get_format_ranges(), [[0], [4, 5], [10]])48 self.assertEqual(49 dut.get_non_format_ranges(), [[1, 2, 3], [6, 7, 8, 9]])50 def test_dos(self):51 original_lines = [52 '#include "line0"\r\n',53 ]54 with self.assertRaisesRegexp(Exception, "DOS newline"):55 FormatterBase("filename.cc", readlines=original_lines)56class TestIncludeFormatter(unittest.TestCase):57 def _split(self, triple_quoted_file_contents):58 lines = triple_quoted_file_contents.split("\n")59 assert len(lines) >= 260 assert lines[0] == "" # Detritus from first triple quote.61 assert lines[-1] == "" # Detritus from last triple quote.62 del lines[0]63 del lines[-1]64 return [line + "\n" for line in lines]65 def _check(self, basename, original, expected, first_differing):66 original_lines = self._split(original)67 expected_lines = self._split(expected)68 dut = IncludeFormatter(69 "drake/dummy/" + basename,70 readlines=original_lines)71 dut.format_includes()72 self.assertEqual(dut.get_all_lines(), expected_lines)73 self.assertEqual(dut.get_first_differing_original_index(),74 first_differing)75 def test_basic(self):76 # A pile of headers gets sorted per cppguide:77 # - The related header78 # - C system files79 # - C++ system files80 # - Other libraries' .h files81 # - Your project's .h files82 original = """83#include "drake/common/drake_assert.h"84#include "drake/dummy/bar.h"85#include "drake/dummy/dut.h"86#include <gtest/gtest.h>87#include <Eigen/Dense>88#include <algorithm>89#include <poll.h>90#include <sys/wait.h>91#include <vector>92"""93 expected = """94#include "drake/dummy/dut.h"95#include <poll.h>96#include <sys/wait.h>97#include <algorithm>98#include <vector>99#include <Eigen/Dense>100#include <gtest/gtest.h>101#include "drake/common/drake_assert.h"102#include "drake/dummy/bar.h"103"""104 self._check("dut.cc", original, expected, 0)105 def test_nothing(self):106 # A file with _no_ include statements.107 original = """108namespace { }109"""110 self._check("dut.cc", original, original, None)111 def test_regroup(self):112 # Wrongly grouped whitespace.113 original = """114#include "drake/dummy/dut.h"115#include <Eigen/Dense>116#include <algorithm>117#include <vector>118#include "drake/common/drake_assert.h"119#include "drake/dummy/bar.h"120#include <gtest/gtest.h>121"""122 expected = """123#include "drake/dummy/dut.h"124#include <algorithm>125#include <vector>126#include <Eigen/Dense>127#include <gtest/gtest.h>128#include "drake/common/drake_assert.h"129#include "drake/dummy/bar.h"130"""131 self._check("dut.cc", original, expected, 2)132 def test_format_off(self):133 # "clang-format off".134 original = """135#include "drake/dummy/dut.h"136// clang-format off137#ifdef FOO138#include <algorithm>139#include <vector>140#else141#include <vector>142#include <algorithm>143#endif144// clang-format on145#include "drake/common/drake_assert.h"146"""147 self._check("dut.cc", original, original, None)148 def test_cc_uses_single_inl(self):149 # Only a single "-inl.h" include.150 original = """151#include "drake/dummy/dut-inl.h"152namespace { }153"""154 self._check("dut.cc", original, original, None)155 def test_cc_uses_inl_and_more(self):156 # Presence of "-inl.h" pattern and other things.157 original = """158#include "drake/dummy/dut-inl.h"159#include "drake/common/drake_assert.h"160#include "drake/common/drake_deprecated.h"161namespace { }162"""163 self._check("xxx.cc", original, original, None)164 def test_target_is_header(self):165 # A header file.166 original = """167#include "drake/common/drake_assert.h"168#include <algorithm>169namespace { }170"""171 expected = """172#include <algorithm>173#include "drake/common/drake_assert.h"174namespace { }175"""176 self._check("dut.h", original, expected, 0)177 def test_target_is_inl(self):178 # An *-inl.h file.179 original = """180#include "drake/dummy/dut.h"181#include <vector>182namespace { }183"""184 self._check("dut-inl.h", original, original, None)185 def test_associated_comment(self):186 # A comment prior to a line.187 original = """188#include "drake/dummy/dut.h"189// Some comment describing the next line.190#include <vector>191namespace { }192"""193 self._check("dut.cc", original, original, None)194 def test_file_opening_comment(self):195 # A comment atop the file with no blank line.196 original = """197/// @file dut.cc198/// Mumble mumble199///200#include <string>201#include <vector>202"""203 self._check("dut.cc", original, original, None)204 def test_internal_related_header(self):205 # Two related headers, guarded by "clang-format off".206 original = """207/* clang-format off (with explanatory comment) */208#include "drake/dummy/dut.h"209#include "drake/dummy/dut_internal.h"210/* clang-format on (with explanatory comment) */211#include <vector>212#include <string>213#include "drake/dummy/drake_assert.h"214#include "drake/dummy/drake_deprecated.h"215"""216 expected = """217/* clang-format off (with explanatory comment) */218#include "drake/dummy/dut.h"219#include "drake/dummy/dut_internal.h"220/* clang-format on (with explanatory comment) */221#include <string>222#include <vector>223#include "drake/dummy/drake_assert.h"224#include "drake/dummy/drake_deprecated.h"225"""226 self._check("dut.cc", original, expected, 5)227 def test_resort_solo_groups(self):228 # Groups of one, but sorted incorrectly.229 original = """230#include "drake/dummy/dut.h"231#include "drake/common/drake_assert.h"232#include <vector>233"""234 expected = """235#include "drake/dummy/dut.h"236#include <vector>237#include "drake/common/drake_assert.h"238"""239 self._check("dut.cc", original, expected, 2)240 def test_nontrivial_reformatting(self):241 # If clang-format changes any lines, we want to fail-fast.242 # (Note the two spaces between #include and the double quote.)243 original_lines = ['#include "nontrivial.h"\n']244 dut = IncludeFormatter("nontrivial.cc", readlines=original_lines)245 dut.format_includes()246 with self.assertRaisesRegexp(Exception, 'not just a shuffle'):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful