Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Should-DSL: Improve readability for should-style expectations
tag: 0.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
INSTALL
LICENSE
README
setup.py

README

Should DSL implemented in Python

The goal is to write a "should" DSL in Python to be as clear as possible.

It would be good to be as close as:

 SOME_VALUE should be equal to ANOTHER VALUE
 or
 SOME_EXCEPTION should be thrown by SOME_CALLABLE
 or
 SOME_VALUE should not be into SOME_CONTAINER
 

Nowadays, the closer it's got is to import DSLObject as _ (underscode) to make it more "invisible".

For example:

_(1).should_be.equal_to(1), will be true
_('should').should_have('oul'), will also be true

A nice example of exceptions would be:
def raise_zerodivisionerror():
    return 1/0
_(ZeroDivisionError).should_be.thrown_by(raise_zero_divisionerror)
Something went wrong with that request. Please try again.