Пример #1
0
try:
    import tappy
    tappy_available = True
except ImportError:
    tappy_available = False

class PPrintTests(unittest.TestCase):
	def test_pprint_builder(self):
		builder = pprint.PrettyPrintBuilder()

		(builder.columns()
				.append()
					.add("blub")
					.add("xyz")
					.up()
				.append()
					.add("g")
					.add("hijk")
					.up()
				.up())
		pprinted = builder.build()

		self.assertEqual(str(pprinted), "blubg\nxyz hijk")

if __name__ == '__main__':
    if tappy_available:
        tappy.unittest_main(tapfile="python-pprint.tap")
    else:
        unittest.main()
Пример #2
0

class VhdlgenTests(unittest.TestCase):
    def test_pprint_builder(self):
        file = vhdlgen.CompilationUnit()

        file.add(vhdlgen.Architecture("behavior", "bla"))

        file.libraries().add("ieee")   \
         .use("std_logic_1164.all") \
         .use("numeric_std.all")

        self.assertEqual(
            str(file.prettyPrint()),
            re.sub(
                "(?m)\t{3}", "", """library ieee;
			use ieee.numeric_std.all;
			use ieee.std_logic_1164.all;


			architecture behavior of bla is
			begin
			end behavior;"""))


if __name__ == '__main__':
    if tappy_available:
        tappy.unittest_main(tapfile="python-vhdlgen.tap")
    else:
        unittest.main()
Пример #3
0
import unittest
from test_pprint import *
from test_vhdlgen import *

try:
    import tappy
    tappy_available = True
except ImportError:
    tappy_available = False

import os
print("PYTHONPATH: " + os.environ["PYTHONPATH"])

if __name__ == '__main__':
    if tappy_available:
        tappy.unittest_main(tapfile="python-pprint-and-vhdlgen.tap")
    else:
        unittest.main()
Пример #4
0
    tappy_available = True
except ImportError:
    tappy_available = False

class VhdlgenTests(unittest.TestCase):
	def test_pprint_builder(self):
		file = vhdlgen.CompilationUnit()

		file.add(vhdlgen.Architecture("behavior", "bla"))

		file.libraries().add("ieee")   \
			.use("std_logic_1164.all") \
			.use("numeric_std.all")

		self.assertEqual(str(file.prettyPrint()),
			re.sub("(?m)\t{3}", "", """library ieee;
			use ieee.numeric_std.all;
			use ieee.std_logic_1164.all;


			architecture behavior of bla is
			begin
			end behavior;"""))


if __name__ == '__main__':
    if tappy_available:
        tappy.unittest_main(tapfile="python-vhdlgen.tap")
    else:
        unittest.main()
Пример #5
0
        dictionary["SECT3"] = False

    def _set_subdict (self, dictionary):
        sub_dict = dictionary.AddSectionDictionary("SUB1")
        sub_dict["SUB_FOO"] = "bar1"
        sub_dict = dictionary.AddSectionDictionary("SUB1")
        sub_dict["SUB_FOO"] = "bar2"

    def test_it (self):
        filename = os.path.join("tests", "test.tpl")
        ctemplate.RegisterTemplate(filename)
        template = ctemplate.Template(filename, ctemplate.DO_NOT_STRIP)
        #self._set_global()  #TODO fix it
        dictionary = ctemplate.Dictionary("my example dict")
        dictionary.SetFilename(filename)
        self._set_methods(dictionary)
        self._set_for_escape_test(dictionary)
        self._set_dict(dictionary)
        self._set_section(dictionary)
        self._set_subdict(dictionary)
        self.assertEqual(dictionary.Dump(), DICTIONARY_EXPECTED_VALUE)
        self.assertEqual(template.Expand(dictionary), EXPECTED_RESULT)
        self.assertEqual(ctemplate.GetBadSyntaxList(True, ctemplate.DO_NOT_STRIP), [])


if __name__ == '__main__':
    if tappy_available:
        tappy.unittest_main(tapfile="python-ctemplate.tap")
    else:
        unittest.main()