diff --git a/pisi/specfilenew.py b/pisi/specfilenew.py index 6a0ed677..9fcda5b6 100644 --- a/pisi/specfilenew.py +++ b/pisi/specfilenew.py @@ -268,8 +268,9 @@ class SpecFile(XmlFile): def write(self, filename): """Write PSPEC file""" + errs = [] self.newDOM() - self.addChild(self.source.elt(self)) - for pkg in self.packages: - self.addChild(pkg.elt(self)) + self.encode(self, self.rootNode(), errs) + if errs: + raise Error(*errs) self.writexml(filename) diff --git a/tests/specfilenewtests.py b/tests/specfilenewtests.py index cb16f23e..d199b699 100644 --- a/tests/specfilenewtests.py +++ b/tests/specfilenewtests.py @@ -78,6 +78,6 @@ class SpecFileNewTestCase(testcase.TestCase): def testCopy(self): util.check_dir(ctx.config.tmp_dir()) self.spec.read("tests/popt/pspec.xml") - self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec.xml')) + self.spec.write(os.path.join(ctx.config.tmp_dir(), 'popt-copy.pspec.xml')) suite = unittest.makeSuite(SpecFileNewTestCase)