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

Chris Spencer chrisspen at gmail.com
Fri May 13 13:35:13 EDT 2016


How do you configure Pytest to create a new Vagrant VM before each test 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.

Has anyone else implemented similar tests with Pytest?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160513/191a4e9a/attachment.html>


More information about the pytest-dev mailing list