def setUp(self): path = os.path.abspath(os.path.dirname(__file__)) templates_path = join(path, "templates") self.fs = fsopendir(templates_path) self.archive = Archive() self.archive.init_cache("templates", SettingsContainer.create(type="dict")) self.archive.init_cache("fragment", SettingsContainer.create(type="dict")) self.engine = MoyaTemplateEngine(self.archive, self.fs, {})
def setUp(self): path = os.path.abspath(os.path.dirname(__file__)) self.fs = fsopendir(path) self.context = Context() self.context['console'] = Console() self.archive = Archive() import_fs = self.fs.opendir("archivetest") self.archive.load_library(import_fs) self.archive.finalize()
def setUp(self): self.called = False path = os.path.abspath(os.path.dirname(__file__)) self.fs = open_fs(path) self.context = Context() self.context["console"] = Console() self.archive = Archive() import_fs = self.fs.opendir("archivetest") self.archive.load_library(import_fs) self.archive.finalize()
def test_ifelse(self): """Test if / elif /else""" tests = [(1, "apple"), (2, "orange"), (3, "pear"), (4, "not a fruit"), (5, "not a fruit")] for n, correct in tests: result = self.archive('moya.tests#ifelse', self.context, None, n=n) self.assertEqual(result, correct) def test_bf(self): """Test BF macro""" # Just because is a moderately complex piece of code with lots of loops context = self.context call = self.archive.call result = call('moya.tests#bf', context, None, program=BF_HELLO) self.assertEqual(result, "Hello World!\n") if __name__ == "__main__": fs = fsopendir('../tests') context = Context() archive = Archive() for dirname in fs.listdir(dirs_only=True): import_fs = fs.opendir(dirname) library = archive.load_library(import_fs) print(archive.call('moya.tests#macrotest1', context)) #print archive.call('archivetest#macroreturnlist', context) #print repr(archive.call('archivetest#testscope1', context)) #print archive.call('archivetest#macrotest1', context)