コード例 #1
0
ファイル: test_stml.py プロジェクト: smulloni/satimol
    def testComp14(self):

        fd, fname=tempfile.mkstemp(suffix=".inc")
        try:
            f=os.fdopen(fd, 'w')
            f.write("""
            Hello from me!
            <:set x `33`:>
            """)
            f.close()        
            self.f.write("""
            I'm going to call a component now.
            <:include `compname`:>
            x is <:val `x`:>.
            Done.
            """)
            self.f.close()
            suffixes=C.DEFAULT_FILE_COMPONENT_SUFFIX_MAP.copy()
            suffixes['.comp']=('string', S.STMLFileComponent)
            suffixes['.inc']=('include', S.STMLFileComponent)
            Configuration.load_dict(dict(componentFileSuffixMap=suffixes))        
            res=C.stringcomp(self.fname, compname=fname)
            print res
            self.failUnless('Hello from me!\n' in res)
            self.failUnless("x is 33" in res)
        finally:
            os.unlink(fname)
コード例 #2
0
ファイル: test_component.py プロジェクト: smulloni/satimol
 def testCallWithCompileCache(self):
     Cfg.load_dict(dict(useCompileMemoryCache=True))
     comp=self.comp1
     d={'a' : 3,
        'x' : 2,
        'y' : 5}
     value=comp(d)
     assert value==(3*(2**5))
コード例 #3
0
ファイル: test_stml.py プロジェクト: smulloni/satimol
 def testComp13(self):
     self.f.write("Hello from me!\n")
     self.f.close()
     fd, fname=tempfile.mkstemp(suffix=".comp")
     try:
         f=os.fdopen(fd, 'w')
         f.write("""
         I'm going to call a component now.
         <:component `compname`:>
         Done.
         """)
         f.close()
         suffixes=C.DEFAULT_FILE_COMPONENT_SUFFIX_MAP.copy()
         suffixes['.comp']=('string', S.STMLFileComponent)
         Configuration.load_dict(dict(componentFileSuffixMap=suffixes))
         res=C.stringcomp(fname, compname=self.fname)
         print res
         self.failUnless('Hello from me!\n' in res)
     finally:
         os.unlink(fname)