Versions

Build a version

Description

testtools is a set of extensions to the Python standard library's unit testing framework. These extensions have been derived from many years of experience with unit testing in Python and come from many different sources. testtools supports Python versions all the way back to Python 2.6.

What better way to start than with a contrived code snippet?:

from testtools import TestCase
from testtools.content import Content
from testtools.content_type import UTF8_TEXT
from testtools.matchers import Equals

from myproject import SillySquareServer

class TestSillySquareServer(TestCase):

    def setUp(self):
        super(TestSillySquare, self).setUp()
        self.server = self.useFixture(SillySquareServer())
        self.addCleanup(self.attach_log_file)

    def attach_log_file(self):
        self.addDetail(
            'log-file',
            Content(UTF8_TEXT
                    lambda: open(self.server.logfile, 'r').readlines()))

    def test_server_is_cool(self):
        self.assertThat(self.server.temperature, Equals("cool"))

    def test_square(self):
        self.assertThat(self.server.silly_square_of(7), Equals(49))

Repository

https://github.com/testing-cabal/testtools.git

Last Built

2 months, 3 weeks ago passed

Owners

Home Page

https://github.com/testing-cabal/testtools

Badge

Tags

python, testing

Project Privacy Level

Public

Short URLs

testtools.readthedocs.io
testtools.rtfd.io

Default Version

latest

'latest' Version

master