1. Mikhail Korobov
  2. fabtest


fabtest /

Filename Size Date modified Message
214 B
fab commands can return results
280 B
Added tag 0.1.5 for changeset c52320d7fca0
74 B
bump version
754 B
bump version
1.5 KB
authors + license year
224 B
Packaging fix. Bump version.
1.9 KB
every single test in all my test suites uses output[0] so make fab command return single value, not a list.
1.1 KB
bump version


Fabtest is a set of utilities and base TestCases that aid testing Fabric scripts against VirtualBox VMs. License is MIT.

VM is rolled back to initial state before each test so tests can do anything with target system; Fabric commands can be run from Python.


pip install fabtest


In order to run tests you'll need VirtualBox 4.x and an OS image. Image should have ssh server installed.

Example VMs (they can be imported to VirtualBox via File->Import Appliance):

Due to bugs in VirtualBox it is better to convert imported .vmdk disk images to .vdi images, e.g.:

VBoxManage clonehd Ubuntu-10.10-disk1.vmdk Ubuntu-10.10-disk.vdi --format VDI

Then detach (and remove) vmdk disk from the VM and attach the vdi image.

After you get the image, make sure it is not running and execute the fabtest-preparevm script (pass your VM name or uid to it):

fabtest-preparevm Lenny

This command configures port forwarding ( to guest 22 port, to guest 80 port) and takes 'fabtest-initial' snapshot used for test rollbacks (it is taken from booted machine in order to speedup tests).

Writing tests

Subclass fabtest.VirtualBoxTest or fabtest.FabTest and use fabtest.fab for fabric commands execution:

from fabric.api import run
from fabtest import FabTest, fab

def whoami():
    return run('whoami')

class MyTestCase(FabTest):
    def test_root_login(self):
        output = fab(whoami)
        self.assertEqual(output, 'root')

Look at source code (and example/runtests.py) for more.