Diff for "ErrorExplanations"

Not logged in - Log In / Register

Differences between revisions 2 and 3
Revision 2 as of 2009-08-04 14:40:36
Size: 9676
Editor: jml
Comment:
Revision 3 as of 2022-01-21 10:47:17
Size: 4529
Editor: cjwatson
Comment: remove old Python 2 errors
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
= ValueError: dictionary update sequence element #0 has length 1; 2 is required =
Example:
{{{
File "lib/canonical/launchpad/pagetests/branches/xx-code-review-messages.txt", line 33, in xx-code-review-messages.txt
Failed example:
    anon_browser.getLink('Reply').click()
Exception raised:
    Traceback (most recent call last):
      File "/home/abentley/src/trunk/lib/zope/testing/doctest.py", line 1260, in __run
        compileflags, 1) in test.globs
      File "<doctest xx-code-review-messages.txt[17]>", line 1, in ?
      File "/home/abentley/src/mp-schema-db/lib/zope/testbrowser/browser.py", line 379, in click
        self.browser.mech_browser.follow_link(self.mech_link)
      File "/home/abentley/src/mp-schema-db/lib/mechanize/_mechanize.py", line 510, in follow_link
        return self.open(self.click_link(link, **kwds))
      File "/home/abentley/src/mp-schema-db/lib/mechanize/_mechanize.py", line 254, in open
        return self._mech_open(url, data)
      File "/home/abentley/src/mp-schema-db/lib/mechanize/_mechanize.py", line 277, in _mech_open
        self._response = UserAgent.open(self, self.request, data)
      File "/usr/lib/python2.4/urllib2.py", line 358, in open
        response = self._open(req, data)
      File "/usr/lib/python2.4/urllib2.py", line 376, in _open
        '_open', req)
      File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
        result = func(*args)
      File "/home/abentley/src/mp-schema-db/lib/zope/testbrowser/testing.py", line 112, in http_open
        return self.do_open(PublisherConnection, req)
      File "/usr/lib/python2.4/urllib2.py", line 993, in do_open
        h.request(req.get_method(), req.get_selector(), req.data, headers)
      File "/home/abentley/src/mp-schema-db/lib/zope/testbrowser/testing.py", line 69, in request
        self.response = self.caller(request_string, handle_errors)
      File "/home/abentley/src/mp-schema-db/lib/canonical/testing/layers.py", line 1021, in my__call__
        response = orig__call__(
      File "/home/abentley/src/trunk/lib/zope/app/testing/functional.py", line 588, in __call__
        request=request_cls, publication=publication_cls)
      File "/home/abentley/src/trunk/lib/zope/app/debug/debug.py", line 86, in _request
        request = request(stdin, env)
      File "/home/abentley/src/mp-schema-db/lib/canonical/launchpad/webapp/servers.py", line 160, in __call__
        request = self.requestfactory(body_instream, environ, response)
      File "/home/abentley/src/mp-schema-db/lib/canonical/launchpad/webapp/servers.py", line 442, in __init__
        super(LaunchpadBrowserRequest, self).__init__(
      File "/home/abentley/src/mp-schema-db/lib/canonical/launchpad/webapp/servers.py", line 395, in __init__
        super(BasicLaunchpadRequest, self).__init__(
      File "/home/abentley/src/trunk/lib/zope/publisher/browser.py", line 221, in __init__
        super(BrowserRequest, self).__init__(body_instream, environ, response)
      File "/home/abentley/src/trunk/lib/zope/publisher/http.py", line 317, in __init__
        self.__setupCookies()
      File "/home/abentley/src/trunk/lib/zope/publisher/http.py", line 421, in __setupCookies
        self._parseCookies(cookie_header, self._cookies)
      File "/home/abentley/src/trunk/lib/zope/publisher/http.py", line 403, in _parseCookies
        c = SimpleCookie(text)
      File "/usr/lib/python2.4/Cookie.py", line 568, in __init__
        if input: self.load(input)
      File "/usr/lib/python2.4/Cookie.py", line 623, in load
        self.update(rawdata)
    ValueError: dictionary update sequence element #0 has length 1; 2 is required
}}}

This can be caused by opening a unicode URL in a page test, and then navgating elsewhere. This is due to some buggy code in Python 2.4 that checks whether the object is an str, not whether it's a basestring. Note that '''canonical_url generates unicode urls'''.


= NameError: name 'OverflowWarning' is not defined =

{{{
Traceback (most recent call last):
  File "jml.py", line 14, in <module>
    from zope.component import getUtility
  File "/srv/bazaar.staging.launchpad.net/staging/launchpad/lib/zope/component/__init__.py", line 23, in <module>
    from zope.component.interfaces import IComponentArchitecture
  File "/srv/bazaar.staging.launchpad.net/staging/launchpad/lib/zope/component/interfaces.py", line 24, in <module>
    from zope.exceptions import NotFoundError
  File "/srv/bazaar.staging.launchpad.net/staging/launchpad/lib/zope/exceptions/__init__.py", line 37, in <module>
    from zope.exceptions._notfounderror import NotFoundError, INotFoundError
  File "/srv/bazaar.staging.launchpad.net/staging/launchpad/lib/zope/exceptions/_notfounderror.py", line 21, in <module>
    from zope.interface.common.interfaces import IKeyError
  File "/srv/bazaar.staging.launchpad.net/staging/launchpad/lib/zope/interface/common/interfaces.py", line 80, in <module>
    classImplements(OverflowWarning, IOverflowWarning)
NameError: name 'OverflowWarning' is not defined
}}}

'''Solution:''' Use python2.4.

This page is to aid debugging unhelpful error messages.

AttributeError: 'NoneType' object has no attribute 'poll'

Running canonical.testing.layers.TwistedAppServerLayer tests:
  Set up canonical.testing.layers.ZopelessLayer in 3.350 seconds.
  Set up canonical.testing.layers.DatabaseLayer in 0.457 seconds.
  Set up canonical.testing.layers.LibrarianLayer in 4.786 seconds.
  Set up canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Set up canonical.testing.layers.LaunchpadScriptLayer in 0.001 seconds.
  Set up canonical.testing.layers.LaunchpadZopelessLayer in 0.000 seconds.
  Set up canonical.testing.layers.TwistedLaunchpadZopelessLayer in 0.000 seconds.
  Set up canonical.testing.layers.TwistedAppServerLayer in 31.229 seconds.
  Running:
    test_lock_with_magic_id (canonical.codehosting.puller.tests.test_scheduler.TestPullerMasterIntegration)Traceback (most recent call last):
  File "./test.py", line 190, in ?
    result = testrunner.run(defaults)
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 238, in run
    failed = not run_with_options(options)
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 403, in run_with_options
    setup_layers, failures, errors)
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 585, in run_layer
    return run_tests(options, tests, layer_name, failures, errors)
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 513, in run_tests
    test(result)
  File "/home/mwh/canonical/checkouts/trunk/lib/twisted/trial/unittest.py", line 632, in __call__
    return self.run(*args, **kwargs)
  File "/home/mwh/canonical/checkouts/init-stack-pull/lib/canonical/codehosting/puller/tests/test_scheduler.py", line 681, in run
    return TrialTestCase.run(self, result)
  File "/home/mwh/canonical/checkouts/trunk/lib/twisted/trial/unittest.py", line 961, in run
    result.stopTest(self)
  File "/home/mwh/canonical/checkouts/trunk/lib/twisted/trial/unittest.py", line 1158, in stopTest
    self.original.stopTest(method)
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 871, in stopTest
    self.testTearDown()
  File "/home/mwh/canonical/checkouts/trunk/lib/zope/testing/testrunner.py", line 755, in testTearDown
    layer.testTearDown()
  File "/home/mwh/canonical/checkouts/init-stack-pull/lib/canonical/testing/profiled.py", line 28, in profiled_func
    return func(cls, *args, **kw)
  File "/home/mwh/canonical/checkouts/init-stack-pull/lib/canonical/testing/layers.py", line 1535, in testTearDown
    LayerProcessController.postTestInvariants()
  File "/home/mwh/canonical/checkouts/init-stack-pull/lib/canonical/testing/profiled.py", line 28, in profiled_func
    return func(cls, *args, **kw)
  File "/home/mwh/canonical/checkouts/init-stack-pull/lib/canonical/testing/layers.py", line 1389, in postTestInvariants
    if cls.appserver.poll() is not None:
AttributeError: 'NoneType' object has no attribute 'poll'

Solution: probably one of "make build", "make schema" or "killing left over librarians".

AttributeError: 'thread._local' object has no attribute 'interaction'

Example:

 Error in test lp.registry.tests.test_distroseries.TestDistroSeriesGetQueueItems.test_get_queue_items
 Traceback (most recent call last):
   File "/home/cjwatson/src/canonical/launchpad/lp-branches/queue-filter-source-bug-33700/lib/lp/testing/__init__.py", line 322, in run
     testMethod()
   File "/home/cjwatson/src/canonical/launchpad/lp-branches/queue-filter-source-bug-33700/lib/lp/registry/tests/test_distroseries.py", line 261, in test_get_queue_items
     pub_source = self.getPubSource(sourcename='alsa-utils')
   File "/home/cjwatson/src/canonical/launchpad/lp-branches/queue-filter-source-bug-33700/lib/lp/soyuz/tests/test_publishing.py", line 159, in getPubSource
     spn = getUtility(ISourcePackageNameSet).getOrCreateByName(sourcename)
 AttributeError: 'thread._local' object has no attribute 'interaction'

Solution: Call login(). This error often happens when trying to use core Launchpad objects when not logged in.

Most of the time login(ANONYMOUS) is good enough. login & ANONYMOUS should be imported from lp.testing.

If you get this error when trying to use the LaunchpadObjectFactory, you should consider making your test a subclass of TestCaseWithFactory.

ErrorExplanations (last edited 2022-01-21 10:47:17 by cjwatson)