Skip to main content

A testsupport utility module for python

Project description


A package for test support


At QWAN we're building some applications in python. We collect usefull stuff in quiltz packages:

  • quiltz-domain contains domain level modules like, entity id's, results, an email anonymizer, validators and parsers
  • quiltz-testsupport (this package) contains test support modules, that supports mainly non unit tests, like integrating with smtp, probing asynchronous results and asserting log statements
  • quiltz-messaging contains a messaging domain concept and an engines to send the messages. Currently only smtp sending is supported.

Modules in this package


With the logging module you can assert log statements in a test using the log_collector fixture:

in test:

from quiltz.testsupport import log_collector
def test_logs_hello(log_collector):
    log_collector.assert_info('hello info')

in production

def foo():
    logger = logging.getLogger()'hello info')


With the probing module you can probe for async results:

from hamcrest import assert_that, equal_to
from quiltz.testsupport import probe_that

def test_stub_server_collects_message_for_recepient(self):        
    message = aMessage(recipient='', sender='', subject='test', body='hello test')

    probe_that(lambda: self.server.messages == [stringified_message(message)])
    # or
    probe_that(lambda: assert_that(self.server.messages, equal_to([
    # or
    probe_that(lambda: self.server.messages, equal_to([


With the smtp module you can create a stub smtp server that collects smtp messages

from hamcrest import assert_that, equal_to
from quiltz.testsupport import probe_that
def server()
    server = StubSmtpServer(hostname='localhost', port=9925)

def test_collects_message_for_recepient(self, server): 
    message_engine = SMTPClientForTest(host='localhost', port='9925')
    message = aMessage(recipient='', sender='', subject='test', body='hello test')

    probe_that(lambda: assert_that(server.messages, equal_to([


pip install quiltz-testsupport

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quiltz_testsupport-0.3.0.tar.gz (5.2 kB view hashes)

Uploaded source

Built Distribution

quiltz_testsupport-0.3.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page