From 839e960059f6c474ddb08909bb1f94a0830e86f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 1 Nov 2005 17:51:04 +0000 Subject: [PATCH] * support specification of output file in print method * fix: print test to write to an external file --- pisi/xmlfile.py | 4 ++-- tests/xmlfiletests.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py index 514bc560..ba10beef 100644 --- a/pisi/xmlfile.py +++ b/pisi/xmlfile.py @@ -298,8 +298,8 @@ class autoxml(oo.autosuper): for formatter in self.__class__.formatters: formatter(self, f, errs) cls.format = format - def print_text(self): - w = Writer() # plain text + def print_text(self, file = sys.stdout): + w = Writer(file) # plain text f = formatter.AbstractFormatter(w) errs = [] self.format(f, errs) diff --git a/tests/xmlfiletests.py b/tests/xmlfiletests.py index e9f3aa4e..50c99ebf 100644 --- a/tests/xmlfiletests.py +++ b/tests/xmlfiletests.py @@ -67,8 +67,9 @@ class AutoXmlTestCase(testcase.TestCase): self.assert_(not a.check()) - a.print_text() - #self.assert_(string.startswith('Name')) + a.print_text(file('/tmp/a', 'w')) + la = file('/tmp/a').readlines() + self.assert_( util.any(lambda x:x.find('18071976')!=-1, la) ) a.write('/tmp/a.xml') def testWriteRead(self):