#28 — multiple tests fail: object has no attribute 'loginPortalOwner'

StateResolved
Version:
AreaFunctionality
Issue typeBug
SeverityMedium
Submitted byTom Elliott
Submitted onNov 15, 2006
Responsible Harald Friessnegger
Target release:
Return to tracker
Last modified on Jan 08, 2009 by Matthew Wilkes


Using ATVM SVN trunk at rev. 7096 + Plone 2.5, Zope (Zope 2.9.3-, python 2.4.3, win32), Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)], PIL 1.1.5.

Many of the tests call self.loginPortalOwner(), which is never defined.

Test output:

Installing ATVocabularyManager ... C:\Program Files\Plone 2\Zope\lib\python\Products\ATVocabularyManager\types\simple\vo
cabulary.py:25: DeprecationWarning: The module, 'Products.CMFCore.CMFCorePermissions' is a deprecated compatiblity alias
 for 'Products.CMFCore.permissions'; please use the new module instead.
  from Products.CMFCore.CMFCorePermissions import AddPortalContent
C:\Program Files\Plone 2\Zope\lib\python\Products\ATVocabularyManager\__init__.py:37: DeprecationWarning: The product_na
me parameter of ToolInit is deprecated and will be ignored in CMF 2.0: ATVocabularyManager
  icon='tool.gif'
done (0.172s)
C:\Program Files\Plone 2\Zope\lib\python\OFS\subscribers.py:74: DeprecationWarning: Products.ATVocabularyManager.tools.v
ocabularylib.VocabularyLibrary.manage_afterAdd is deprecated and will be removed in Zope 2.11, you should use event subs
cribers instead, and meanwhile mark the class with <five:deprecatedManageAddDelete/>
  DeprecationWarning)
..C:\Program Files\Plone 2\Zope\lib\python\OFS\subscribers.py:74: DeprecationWarning: Products.ATVocabularyManager.tools
.vocabularylib.VocabularyLibrary.manage_beforeDelete is deprecated and will be removed in Zope 2.11, you should use even
t subscribers instead, and meanwhile mark the class with <five:deprecatedManageAddDelete/>
  DeprecationWarning)
.EE.EEEEEEE.EEE.E.E.E.E
======================================================================
ERROR: the tool and all the vocabularies get deleted
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testATVocabularyManager.py", line 64, in test_vocabulariesDeletedAtUninstall
    self.loginPortalOwner()
AttributeError: 'TestATVocabularyManager' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: the tool and all the vocabularies are preserved when
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testATVocabularyManager.py", line 107, in test_vocabulariesPreservedAtReinstall
    self.loginPortalOwner()
AttributeError: 'TestATVocabularyManager' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testAddTerm (testSimpleVocabulary.TestSimpleVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 46, in testAddTerm
    self.setupSimpleVocabularyContainer()
  File "testSimpleVocabulary.py", line 24, in setupSimpleVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: A SimpleVocabularyTerm simply returns a list containing it's key
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 150, in testGetTermKeyPath
    self._createTestVocabulary()
  File "testSimpleVocabulary.py", line 82, in _createTestVocabulary
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testGetVocabularyByName (testSimpleVocabulary.TestSimpleVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 41, in testGetVocabularyByName
    self.setupSimpleVocabulary()
  File "testSimpleVocabulary.py", line 30, in setupSimpleVocabulary
    self.setupSimpleVocabularyContainer()
  File "testSimpleVocabulary.py", line 24, in setupSimpleVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testImportCSVwoTitlerow (testSimpleVocabulary.TestSimpleVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 56, in testImportCSVwoTitlerow
    self.setupSimpleVocabularyContainer()
  File "testSimpleVocabulary.py", line 24, in setupSimpleVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testSetupSimpleVocabulary (testSimpleVocabulary.TestSimpleVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 37, in testSetupSimpleVocabulary
    self.setupSimpleVocabulary()
  File "testSimpleVocabulary.py", line 30, in setupSimpleVocabulary
    self.setupSimpleVocabularyContainer()
  File "testSimpleVocabulary.py", line 24, in setupSimpleVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: Test if SimpleVocabulary works with Linguaplone
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 97, in testTranslations
    self._createTestVocabulary()
  File "testSimpleVocabulary.py", line 82, in _createTestVocabulary
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: Test if Simplevocabulary Works without Linguaplone
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testSimpleVocabulary.py", line 165, in testWithoutLinguaplone
    self._createTestVocabulary()
  File "testSimpleVocabulary.py", line 82, in _createTestVocabulary
    self.loginPortalOwner()
AttributeError: 'TestSimpleVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: tests if treevocabulary works fine with linguaplone
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 86, in __call__
    self.setUp()
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\PortalTestCase.py", line 62, in setUp
    self.afterSetUp()
  File "testTreeVocabulary.py", line 26, in afterSetUp
    self.loginPortalOwner()
AttributeError: 'TestTreeVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: Test for the method term.getTermKeyPath.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 86, in __call__
    self.setUp()
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\PortalTestCase.py", line 62, in setUp
    self.afterSetUp()
  File "testTreeVocabulary.py", line 26, in afterSetUp
    self.loginPortalOwner()
AttributeError: 'TestTreeVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testAddTerm (testVdexVocabulary.TestVdexVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testVdexVocabulary.py", line 40, in testAddTerm
    self.setupVdexVocabularyContainer()
  File "testVdexVocabulary.py", line 22, in setupVdexVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestVdexVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testGetVocabularyByName (testVdexVocabulary.TestVdexVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testVdexVocabulary.py", line 35, in testGetVocabularyByName
    self.setupVdexVocabulary()
  File "testVdexVocabulary.py", line 28, in setupVdexVocabulary
    self.setupVdexVocabularyContainer()
  File "testVdexVocabulary.py", line 22, in setupVdexVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestVdexVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testGetXMLBinding (testVdexVocabulary.TestVdexVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testVdexVocabulary.py", line 58, in testGetXMLBinding
    self.setupVdexVocabularyContainer()
  File "testVdexVocabulary.py", line 22, in setupVdexVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestVdexVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: testSetXMLBinding (testVdexVocabulary.TestVdexVocabulary)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\profiler.py", line 98, in __call__
    testMethod()
  File "testVdexVocabulary.py", line 70, in testSetXMLBinding
    self.setupVdexVocabularyContainer()
  File "testVdexVocabulary.py", line 22, in setupVdexVocabularyContainer
    self.loginPortalOwner()
AttributeError: 'TestVdexVocabulary' object has no attribute 'loginPortalOwner'

======================================================================
ERROR: Doctest: search_treevocabulary.txt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Plone 2\Zope\lib\python\zope\testing\doctest.py", line 2179, in setUp
    self._dt_setUp(test)
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\zopedoctest\functional.py", line 239, in setUp
    test_instance.setUp()
  File "C:\Program Files\Plone 2\Zope\lib\python\Testing\ZopeTestCase\PortalTestCase.py", line 62, in setUp
    self.afterSetUp()
  File "test_searchTreeVocabulary.py", line 30, in afterSetUp
    self.loginPortalOwner()
AttributeError: 'TestSearchTreeVocabulary' object has no attribute 'loginPortalOwner'

----------------------------------------------------------------------
Ran 25 tests in 3.656s

FAILED (errors=16)
Steps to reproduce:
Set up test framework
From Products\ATVocabularyManager\tests, execute: runalltests.py
Added byHarald FriessneggeronNov 15, 2006 09:13 PM
Issue state: unconfirmedopen
Responsible manager: frisijensens
atvocabularymanager is not using the "real" PloneTestCase
from Products.PloneTestCase import PloneTestCase

but some sort of that is shipped with plone2.1
from Products.CMFPlone.tests import PloneTestCase
(which is a quite old version, i can remember that loginPortalOwner changed to loginAsPortalOwner probably a year or more ago)

plone2.5 imports the real plonetestcase at this point and this on only has loginAsPortalOwner.

one should think that
changing the imports to
from Products.PloneTestCase import PloneTestCase
and all the "loginPortalOwner" to "loginAsPortalOwner"
should solve the problem but i'm running in some strange exception

Error in test /home/frisi/lovely_systems/instances/zope/alpha-alpha/Products/ATVocabularyManager/doc/search_treevocabulary.txt
Traceback (most recent call last):
  File "/opt/python-2.4.3/lib/python2.4/unittest.py", line 251, in run
    self.setUp()
  File "/opt/zope-2.9.5/lib/python/zope/testing/doctest.py", line 2276, in setUp
    self._dt_setUp(test)
  File "/opt/zope-2.9.5/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py", line 254, in setUp
    test_instance.setUp()
  File "/opt/zope-2.9.5/lib/python/Testing/ZopeTestCase/PortalTestCase.py", line 60, in setUp
    self.portal = self._portal()
  File "/home/frisi/lovely_systems/instances/zope/alpha-alpha/Products/PloneTestCase/PloneTestCase.py", line 67, in _portal
    return self.getPortal(1)
  File "/home/frisi/lovely_systems/instances/zope/alpha-alpha/Products/PloneTestCase/PloneTestCase.py", line 80, in getPortal
    return getattr(self.app, portal_name)
AttributeError: plone


would be great if you could do the refactoring of the testcases to make them use PloneTestCase correctly.

maybe you could do some monkeypatching to make the test run on your machine:
self.loginPortalOwner = self.loginAsPortalOwner
Added byTom ElliottonNov 21, 2006 07:57 PM
I have attempted a refactoring as requested; mega-patch attached (every file in /tests gets changed somehow, except runalltests.py, which I think is now obsolete?).

This should be checked over and looked at closely by others because:

(1) I am using Windows, and so have had to hack together a test environment (see: http://plone.org/[…]/attributeerror-test_user_1_; patch includes a batch file for running tests on my machine ... note environment variable values), and

(2) I have limited experience setting up plone test cases (I have tried to follow http://plone.org/documentation/tutorial/testing). I would expect non-windows users to be able to run this batch of tests in accordance with the guidance in that tutorial.

I have resisted the urge to add a couple of new tests; however, I have added one in testATVocabularyManager.py to verify that all expected content types are available after install.

All tests now execute successfully on my box, except:

    32/32 (100.0%) ... oducts\ATVocabularyManager\doc\search_treevocabulary.txt

Failure in test C:\Program Files\Plone 2\Zope\lib\python\Products\ATVocabularyManager\doc\search_treevocabulary.txt
Failed doctest test for search_treevocabulary.txt
  File "C:\Program Files\Plone 2\Zope\lib\python\Products\ATVocabularyManager\doc\search_treevocabulary.txt", line 0

----------------------------------------------------------------------
File "C:\Program Files\Plone 2\Zope\lib\python\Products\ATVocabularyManager\doc\search_treevocabulary.txt", line 55, in
search_treevocabulary.txt
Failed example:
    engines
Expected:
    <TreeVocabulary at /portal/portal_vocabularies/enginetypes>
Got:
    <TreeVocabulary at /plone/portal_vocabularies/enginetypes>


  Ran 32 tests with 1 failures and 0 errors in 21.312 seconds.



There are some non-fatal (to the test) cataloging errors as well:

    5/32 (15.6%) test_vocabulariesDeletedAtUninstall (...stATVocabularyManager)2006-11-21 13:40:48 ERROR Zope.ZCatalog u
ncatalogObject unsuccessfully attempted to uncatalog an object with a uid of portal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of /p
lone/portal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of po
rtal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of /p
lone/portal_vocabularies/foo/bar.
2006-11-21 13:40:48 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of /p
lone/portal_vocabularies/foo.

Added by(anonymous)onJan 01, 2007 11:37 AM
Also the search_treevocabulary-doctest fails with Plone 2.5 cause PloneTestCase creates a Portal with the name plone.

Index: doc/search_treevocabulary.txt
===================================================================
--- doc/search_treevocabulary.txt (Revision 7308)
+++ doc/search_treevocabulary.txt (Arbeitskopie)
@@ -53,7 +53,7 @@

   >>> engines = atvm.getVocabularyByName('enginetypes')
   >>> engines
- <TreeVocabulary at /portal/portal_vocabularies/enginetypes>
+ <TreeVocabulary at /plone/portal_vocabularies/enginetypes>
Added byrsantosonFeb 09, 2007 06:24 PM
I've checked in some changes in atvm tests (before seeing this thread). Now it uses PloneTestCase.PloneTestCase instead of CMFPlone.tests.PloneTestCase. Tests are now running correctly, I think, in Plone-2.1 and Plone-2.5.

It would be nice if someone confirm that the problem is really fixed.

note: there are currently 4 errors, related to `getTranslations` (both in Plone-2.1 and Plone-2.5), but i think they are not related to this.
Added byTom ElliottonMar 02, 2007 03:43 AM
With the following setup, I have all but the four getTranslation tests running:

Plone 2.5.2, CMF-1.6.2, Zope (Zope 2.9.5-final, python 2.4.3, win32), Five 1.4.2, Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)], PIL 1.1.5, LinguaPlone 0.9.0, PloneLanguageTool 1.5., ATVM from svn trunk at r7545.

After applying rsantos' patch from http://plone.org/products/atvocabularymanager/issues/34/

all tests run clean.
Added byJens W. KleinonMar 02, 2007 09:08 AM
Issue state: openin-progress
Responsible manager: jensensfrisi
please confirm it and close it :)
Added byHarald FriessneggeronMar 02, 2007 02:14 PM
Issue state: in-progressresolved
can confirm that the tests are running on plone2.5.2 zope2.9.5
thanks Tom Elliott for providing a patch and rsantos for fixing/migrating the tests.

Add response

Please enter your response below