No "nice" way to run tests

Bug #893563 reported by Jonathan Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pkgme service
Fix Released
High
James Westby

Bug Description

If we want pkgme-binary to be a dependency of pkgme-service, and we wish to actually trigger a run of the backend from the tests (as in lp:~jml/pkgme-service/actually-run-pkgme) then we need to run the tests in a virtualenv. "fab test" does *not* do that by default, instead running the tests using the Python that is inside the virtualenv and hoping for the best. If you active the virtualenv and run "fab test" inside it, the tests run but bzr does not work, so it's not great for rapid test->edit->test->commit cycles.

$ bzr st
cannot import name get_trees_and_branches_to_diff
cannot import name info

Jonathan Lange (jml)
Changed in pkgme-service:
status: New → Triaged
importance: Undecided → High
Revision history for this message
James Westby (james-w) wrote :

We could have pkgme setup PYTHONPATH to mirror sys.path when running an external script.
That would allow the virtualenv to propogate down.

I don't think it's too distasteful.

Thanks,

James

Revision history for this message
Łukasz Czyżykowski (lukasz-czyzykowski) wrote :

There's venv/bin/activate_this.py file which can be used from inside fab tasks to get access to the virtualenv.

Normally it's used something like thist:

execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))

At that point all paths and some other bits of magic are properly set up and all packages from the virtualenv are accessible to the code.

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 893563] Re: No "nice" way to run tests

On Thu, 08 Mar 2012 07:24:40 -0000, Łukasz Czyżykowski <email address hidden> wrote:
> There's venv/bin/activate_this.py file which can be used from inside fab
> tasks to get access to the virtualenv.
>
> Normally it's used something like thist:
>
> execfile('path/to/activate_this.py',
> dict(__file__='path/to/activate_this.py'))
>
> At that point all paths and some other bits of magic are properly set up
> and all packages from the virtualenv are accessible to the code.

The fabtask currently runs virtualenv/bin/python manage.py test. The
problem is that this doesn't set PYTHONPATH. It looks like
activate_this.py doesn't set that either?

Thanks,

James

Revision history for this message
James Westby (james-w) wrote :

On Thu, 08 Mar 2012 09:37:09 -0500, James Westby <email address hidden> wrote:
> On Thu, 08 Mar 2012 07:24:40 -0000, Łukasz Czyżykowski <email address hidden> wrote:
> > There's venv/bin/activate_this.py file which can be used from inside fab
> > tasks to get access to the virtualenv.
> >
> > Normally it's used something like thist:
> >
> > execfile('path/to/activate_this.py',
> > dict(__file__='path/to/activate_this.py'))
> >
> > At that point all paths and some other bits of magic are properly set up
> > and all packages from the virtualenv are accessible to the code.
>
> The fabtask currently runs virtualenv/bin/python manage.py test. The
> problem is that this doesn't set PYTHONPATH. It looks like
> activate_this.py doesn't set that either?

Hmm, it's not PYTHONPATH, as activate doesn't set that either. I'm not
sure what it is then, but something definitely changes running activate
compared to executing the python without first activating.

Thanks,

James

Jonathan Lange (jml)
Changed in pkgme-service:
assignee: nobody → James Westby (james-w)
status: Triaged → Fix Released
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.