[TIP] Sclara is a Python testing DSL

Ned Batchelder ned at nedbatchelder.com
Mon Mar 26 18:31:31 PDT 2012

On 3/24/2012 5:00 PM, John MacKenzie wrote:
> http://github.com/198d/sclara
> I wrote this library based on a thought I had at the TiP BoF this year 
> (hence the name "s(anta)clara"): RSpec for Python (unoriginal idea) 
> written entirely with context managers (original idea, hopefully). I 
> had been writing Ruby for 3 years up until about December of last year 
> and have been writing Python full time since then. What I like most 
> about RSpec is the way you define and organize tests. You end up 
> grouping similar test cases in a sort of hierarchical manner (without 
> resorting to OOP, which I hate the most about writing tests with 
> unittest) and get things like cumulative setup/teardown from parent 
> contexts while producing an english statement that is either true or 
> false after the test is run. These are the main ideas I tried to 
> capture with sclara. Context mangers, at first glance kind of make 
> sense; if you make a quick sketch of what this might look like, you 
> get something like this:
> with description('Our object under test'):
>   with test('does something'):
>     assert True
>   with test('does something else'):
>     assert True
>   with description('when some condition is met'):
>     with test('acts a specific way'):
>       assert True

How is this similar to or different than Lettuce?  Sorry, I have no 
experience with any of these rubyesque tools.


More information about the testing-in-python mailing list