<rect height='25' x='100' style='fill:#E5965B ' width='245' y='55'/><text x='20' y='73'>CLARK</text><text x='355' y='73'>2450</text> <rect height='25' x='100' style='fill:#E5D15B ' width='390' y='90'/><text x='20' y='108'>KING</text><text x='500' y='108'>3900</text> <rect height='25' x='100' style='fill:#BEE55B ' width='130' y='125'/><text x='20' y='143'>MILLER</text><text x='240' y='143'>1300</text> </g> </svg>""" # def test_transform(self): # import sys # from amara.xslt import transform # # result = transform(self.source, self.transform, output=io) # # #FIXME: the numerics break under Python 2.3 # test_harness.XsltTest(tester, source, [sheet], expected_1, # extensionModules=[__name__]) # # self.assert_(treecompare.html_compare(self.expected, io.getvalue())) # # return # Hide the test framework from nose del xslt_test if __name__ == '__main__': test_main()
import sys from amara.xslt import transform #Create the matrix to be transposed from Ft.Xml.Domlette import implementation doc = implementation.createDocument(None, 'table', None) counter = 1 for row in range(SIZE): row_elem = doc.createElementNS(None, 'row') doc.documentElement.appendChild(row_elem) for col in range(SIZE): col_elem = doc.createElementNS(None, 'column') row_elem.appendChild(col_elem) content = doc.createTextNode(str(counter)) col_elem.appendChild(content) counter = counter + 1 stream = cStringIO.StringIO() from Ft.Xml.Domlette import Print Print(doc, stream) self.source = stringsource(stream.getvalue()) result = transform(self.source, self.transform, output=io) self.assert_(treecompare.html_compare(self.expected, io.getvalue())) return if __name__ == '__main__': test_main()
def __new__(cls, name, bases, namespace): if 'test_methods' not in namespace: if 'evaluate_method' in namespace: test_methods = ('evaluate', namespace['evaluate_method']) namespace['test_methods'] = test_methods return base_metaclass.__new__(cls, name, bases, namespace) def new_tst_method(cls, expected, factory, args, *test_args): if not test_args: test_args = (context(DOC, 1, 1), ) def test_method(self): expr = factory(*args) for method_name in self.test_methods: result = getattr(expr, method_name)(*test_args) self.assertIsInstance(result, type(expected)) self.assertEquals(result, expected) return test_method if __name__ == '__main__': from amara.test import test_main test_main( # list of module names to test # 'test_basic_expr', # basic expressions # 'test_function_calls', # basic expressions # 'test_nodeset_expr', # basic expressions # 'test_boolean_expr', # number expressions # 'test_number_expr', # number expressions )
name) def test_processor(self): try: xslt_test.test_processor(self) except self.error_class, error: expected = self._format_error(self.error_class, self.error_code) compared = self._format_error(self.error_class, getattr(error, 'code', None)) self.assertEquals(expected, compared) else: expected = self._format_error(self.error_class, self.error_code) self.fail('%s not raised' % expected) if __name__ == '__main__': from amara.test import test_main, test_case, TestError import glob module_dir = os.path.dirname(os.path.abspath(__file__)) pattern = os.path.join(module_dir, 'test_*.py') test_modules = [ os.path.basename(fn)[:-3] for fn in glob.glob(pattern) ] # Re-arrange the modules /slightly/ for name in ('test_basics', 'test_exslt', 'test_borrowed'): try: test_modules.remove(name) except ValueError: pass else: test_modules.append(name) test_modules.remove('test_borrowed') test_main(*test_modules)
def test_processor(self): try: xslt_test.test_processor(self) except self.error_class, error: expected = self._format_error(self.error_class, self.error_code) compared = self._format_error(self.error_class, getattr(error, 'code', None)) self.assertEquals(expected, compared) else: expected = self._format_error(self.error_class, self.error_code) self.fail('%s not raised' % expected) if __name__ == '__main__': from amara.test import test_main, test_case, TestError import glob module_dir = os.path.dirname(os.path.abspath(__file__)) pattern = os.path.join(module_dir, 'test_*.py') test_modules = [os.path.basename(fn)[:-3] for fn in glob.glob(pattern)] # Re-arrange the modules /slightly/ for name in ('test_basics', 'test_exslt', 'test_borrowed'): try: test_modules.remove(name) except ValueError: pass else: test_modules.append(name) test_modules.remove('test_borrowed') test_main(*test_modules)
test_methods = ('evaluate',) class __metaclass__(base_metaclass): def __new__(cls, name, bases, namespace): if 'test_methods' not in namespace: if 'evaluate_method' in namespace: test_methods = ('evaluate', namespace['evaluate_method']) namespace['test_methods'] = test_methods return base_metaclass.__new__(cls, name, bases, namespace) def new_tst_method(cls, expected, factory, args, *test_args): if not test_args: test_args = (context(DOC, 1, 1),) def test_method(self): expr = factory(*args) for method_name in self.test_methods: result = getattr(expr, method_name)(*test_args) self.assertIsInstance(result, type(expected)) self.assertEquals(result, expected) return test_method if __name__ == '__main__': from amara.test import test_main test_main(# list of module names to test # 'test_basic_expr', # basic expressions # 'test_function_calls', # basic expressions # 'test_nodeset_expr', # basic expressions # 'test_boolean_expr', # number expressions # 'test_number_expr', # number expressions )