Installation

At this point you should consider Ivoire to be experimental, and there are
likely plenty of bugs to address, so please file them as you run into them on
the issue tracker.

A Small Example

To write specs using Ivoire, simply import and use ivoire.describe. You can
then execute the spec using the included ivoire test runner.

Here’s an example of what a specification looks like.

fromivoireimportdescribe,contextclassCalculator(object):defadd(self,x,y):returnx+ydefdivide(self,x,y):returnx/ywithdescribe(Calculator)asit:@it.beforedefbefore(test):test.calc=Calculator()withit("adds two numbers")astest:test.assertEqual(test.calc.add(2,4),6)withit("multiplies two numbers")astest:test.assertEqual(test.calc.multiply(2,3),6)withcontext(Calculator.divide):withit("divides two numbers")astest:test.assertEqual(test.calc.divide(8,4),2)withit("doesn't divide by zero")astest:withtest.assertRaises(ZeroDivisionError):test.calc.divide(8,0)

You can find this example at examples/calculator_spec.py, alongside a few
others.

After installing Ivoire, running the example above with
ivoire examples/calculator_spec.py should produce:

If you’d like a more verbose output, try passing the -v command line flag.

At some point in the (hopefully very near) future, when I’ve sorted out an
import hook, Ivoire will also be able to be run as
ivoire transform `which nosetests` --testmatch='(?:^|[\b_\./-])[Ss]pec',
which will transform specs automatically into normal unittest.TestCases.
Work on this is in progress.

Running the Test Suite

Ivoire’s test suite is currently written mostly in itself, but it still has a
small section that is written using the standard unittest test cases.

You can run Ivoire’s test suite by running tox in the root of the
repository checkout after installing tox via your package manager or with
pip install tox. This will run both parts of the suite.

Contributing

I’m Julian Berman.

You can find me on Freenode in #python-testing and various other channels
(nick: tos9) if you’d like to chat, or if there’s enough interest in such a
thing, in ##ivoire.