diff --git a/gen/generator.py b/gen/generator.py index a049b3c..48b9dad 100644 --- a/gen/generator.py +++ b/gen/generator.py @@ -182,7 +182,8 @@ class Generator: for name, elem in moduleOrClass.__dict__.iteritems(): if type(elem) in (staticmethod, classmethod): elem = elem.__get__(name) - if hasattr(elem, '__doc__') and elem.__doc__ and \ + if callable(elem) and (type(elem) != types.ClassType) and \ + hasattr(elem, '__doc__') and elem.__doc__ and \ (elem.__doc__.find('>>>') != -1): res = True self.totalNumberOfTests += 1 diff --git a/gen/plone25/mixins/TestMixin.py b/gen/plone25/mixins/TestMixin.py index b592121..d58cc20 100644 --- a/gen/plone25/mixins/TestMixin.py +++ b/gen/plone25/mixins/TestMixin.py @@ -5,7 +5,7 @@ import os, os.path, sys class TestMixin: '''This class is mixed in with any PloneTestCase.''' def createUser(self, userId, roles): - '''Creates a user p_name p_with some p_roles.''' + '''Creates a user with id p_userId with some p_roles.''' pms = self.portal.portal_membership pms.addMember(userId, 'password', [], []) self.setRoles(roles, name=userId) @@ -16,7 +16,7 @@ class TestMixin: self.login(userId) def getNonEmptySubModules(self, moduleName): - '''Returns the list fo sub-modules of p_app that are non-empty.''' + '''Returns the list of sub-modules of p_app that are non-empty.''' res = [] try: exec 'import %s' % moduleName diff --git a/gen/plone25/templates/testAll.py b/gen/plone25/templates/testAll.py index 627e4f4..7eb0b78 100644 --- a/gen/plone25/templates/testAll.py +++ b/gen/plone25/templates/testAll.py @@ -9,7 +9,9 @@ from appy.gen.plone25.mixins.TestMixin import TestMixin, beforeTest, afterTest # Initialize Zope & Plone test systems ----------------------------------------- ZopeTestCase.installProduct('') -PloneTestCase.setupPloneSite(products=['']) +ZopeTestCase.installProduct('PloneLanguageTool') +PloneTestCase.setupPloneSite(products=['', + 'PloneLanguageTool']) class Test(PloneTestCase.PloneTestCase, TestMixin): '''Base test class for test cases.''' diff --git a/gen/plone25/wrappers/__init__.py b/gen/plone25/wrappers/__init__.py index eb2b06e..4ecde6f 100644 --- a/gen/plone25/wrappers/__init__.py +++ b/gen/plone25/wrappers/__init__.py @@ -94,6 +94,8 @@ class AbstractWrapper: def get_fields(self): return self.o.getAllAppyTypes() fields = property(get_fields) + def getField(self, name): return self.o.getAppyType(name) + def link(self, fieldName, obj): '''This method links p_obj (which can be a list of objects) to this one through reference field p_fieldName.''' diff --git a/shared/xml_parser.py b/shared/xml_parser.py index a54c0d0..1d5fca9 100644 --- a/shared/xml_parser.py +++ b/shared/xml_parser.py @@ -167,8 +167,15 @@ class XmlParser(ContentHandler, ErrorHandler): # Put a question mark instead of raising an exception. self.characters('?') - def parse(self, xmlContent, source='string'): - '''Parses the XML file or string p_xmlContent.''' + def parse(self, xml, source='string'): + '''Parses a XML stream. + * If p_source is "string", p_xml must be a string containing + valid XML content. + * If p_source is "file": p_xml can be: + - a string containing the path to the XML file on disk; + - a file instance opened for reading. Note that in this case, this + method will close it. + ''' try: from cStringIO import StringIO except ImportError: @@ -178,10 +185,13 @@ class XmlParser(ContentHandler, ErrorHandler): self.parser.setFeature(feature_external_ges, False) inputSource = InputSource() if source == 'string': - inputSource.setByteStream(StringIO(xmlContent)) + inputSource.setByteStream(StringIO(xml)) else: - inputSource.setByteStream(xmlContent) + if not isinstance(xml, file): + xml = file(xml) + inputSource.setByteStream(xml) self.parser.parse(inputSource) + if isinstance(xml, file): xml.close() return self.res # ------------------------------------------------------------------------------