_pythonpath only sometimes importable in tests

Bug #737497 reported by Jonathan Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
High
Unassigned

Bug Description

If you write a test like this::

  class TestSomething(TestCase):
    def test_a_thing(self):
      import _pythonpath

And run it by itself, it will fail, being unable to import _pythonpath. However, there are tests in the Launchpad test suite (notably, lp.services.job.tests.test_runner.TestTwistedJobRunner) that do that successfully when run as part of the whole test suite, but fail when run stand alone.

Tags: easy tech-debt
Revision history for this message
Jonathan Lange (jml) wrote :

Some debugging notes:

  * This appears to be unrelated to bug 505913
  * As best as I can tell, this is nothing to do with zope.testing's knack of running much of the suite in subprocesses. I've tried various combinations of ZopeTestInSubProcess and running the test after a layer that cannot be torn down and nothing seems to affect importing _pythonpath

Revision history for this message
Jonathan Lange (jml) wrote :

As far as I can tell, the only in-process manipulation of sys.path comes from test_shhh, which adds the 'utilities' directory to sys.path on import. utilities contains a _pythonpath, and this would explain how this test can pass when run in isolation.

Changed in launchpad:
status: New → In Progress
assignee: nobody → Jonathan Lange (jml)
Revision history for this message
Jonathan Lange (jml) wrote :

It's definitely test_shhh's fault. For lp.services.job.tests.test_runner.TestTwistedJobRunner, I've done the sys.path manipulation manually. To fix this bug properly, test_shhh needs to clean up after itself.

Changed in launchpad:
status: In Progress → Incomplete
status: Incomplete → Triaged
assignee: Jonathan Lange (jml) → nobody
tags: added: tech-debt
Changed in launchpad:
importance: Undecided → High
Revision history for this message
Robert Collins (lifeless) wrote :

test_sssh should use a proper namespace to import stuff :) probably want to build it in buildout too.

tags: added: easy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.