Пример #1
0
    def testOutfileUnicode(self):
        tmpl = "Тодор"
        expected_output = "Тодор"
        outfile = os.path.join(TMP, 'outfile_%s.tmpl' % (os.getpid()))

        render(content=tmpl, outfile=outfile)

        with open(outfile, 'r') as f:
            output = f.read()

        os.remove(outfile)

        self.assertEqual(output, expected_output)
Пример #2
0
    def testPath(self):
        tmpl = "X"
        expected_output = "X"

        infile = os.path.join(TMP, 'infile_%s.tmpl' % (os.getpid()))
        with open(infile, 'w') as f:
            f.write(tmpl)

        output = render(infile, path=[TMP])

        os.remove(infile)

        self.assertEqual(output, expected_output)
Пример #3
0
    def testInfileUnicode(self):
        tmpl = "Тодор"
        if PY2:
            tmpl = tmpl.decode('utf-8')
        expected_output = tmpl

        infile = os.path.join(TMP, 'infileunicode_%s.tmpl' % (os.getpid()))
        with codecs.open(infile, 'w', 'utf-8') as f:
            f.write(tmpl)

        output = render(infile)

        os.remove(infile)

        self.assertEqual(output, expected_output)
Пример #4
0
    def testEmptyInput(self):

        with self.assertRaises(RuntimeError):
            render()
Пример #5
0
 def testDelimiters(self):
     content = "[[True]]"
     self.assertEqual(render(content=content, delimiters="[[ ]]"), "")
Пример #6
0
 def testContext(self):
     content = "{{=i}}"
     context = dict(i=300)
     self.assertEqual(render(content=content, context=context), "300")
Пример #7
0
 def testContent(self):
     content = "X"
     self.assertEqual(render(content=content), "X")