[pytest-dev] Running each test in a Vagrant VM?

Bruno Oliveira nicoddemus at gmail.com
Mon May 16 11:50:37 EDT 2016


Hi Chris,

On Fri, May 13, 2016 at 2:35 PM Chris Spencer <chrisspen at gmail.com> wrote:

> How do you configure Pytest to create a new Vagrant VM before each test
> and destroy it afterwards?
>

I've not done something similar myself, but I would implement this feature
as a fixture, which would create a vagrant vm and destroy it afterwards.


> I'm trying to test a sysadmin tool based on Fabric (
> http://www.fabfile.org/), and so the tests need a fresh target server in
> a known state to login to.
>
> I tried implementing a Pytest plugin, similar to the Fabtools project (
> https://github.com/ronnix/fabtools/blob/master/fabtools/tests/functional_tests/conftest.py)
> but it's unreliable. Each test seems to pass when I run them separately,
> but when I run all my tests together, there's some bug that's preventing
> the VM from being destroyed and re-created properly, causing many tests to
> fail when the previous test leaves the VM in an unexpected state.
>

Perhaps can you post the error you are getting exactly? Also others might
have more experience with starting/shutdown vagrant from within python.

Cheers,
Bruno.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160516/eb9f7f2d/attachment.html>


More information about the pytest-dev mailing list