skip to navigation
skip to content

testinstances 0.2.0

Managed test instances for integration tests

Latest Version: 0.3.0

testinstances is a set of managed instance wrappers to make integration testing with redis and mongodb easier. If you have the binaries on your path, it can handle creating and destroying sandboxed instances for you to test with.


The API is straightforward and easily embedeed in setup/teardown functions. It also automatically returns a connection to the instance.:

import unittest

from testinstances import RedisInstance

class TestSomeJunk(unittest.TestCase):
  def setUp(self):
    # Set up an instance on port 12345
    self.redis = RedisInstance(12345)

  def tearDown(self):

  def test_stuff(self):
    self.redis.conn.set('foo', 'bar')
    self.assertEqual(self.redis.conn.get('foo'), 'bar')

Or, if you wanted to be fancy and avoid the process creation/termination cost for every test case:

import unittest

from testinstances import MongoInstance

class TestSomeJunk(unittest.TestCase):
  def setUpClass(cls):
    # Set up an instance on port 12345
    cls.mongo = MongoInstance(12345)

  def tearDownClass(cls):

  def setUp(self):
    # All instance types implement ``flush``

  def test_stuff(self):
    collection = self.mongo.conn['someDB']['someCollection']
    collection.insert({'foo': 'bar'})
    self.assertEqual(collection.find({'foo': 'bar'}).next()['foo'], 'bar')


  • New Instance Kinds
    • Kafka
    • Zookeeper
  • Documentation and ReadTheDocs
  • Travis-CI
File Type Py Version Uploaded on Size
testinstances-0.2.0.tar.gz (md5) Source 2014-06-30 5KB