import time from sclara import description, test from sclara.expectation import expect from sclara.runner import greenlet_runner, delayed_runner with delayed_runner('delayed runner for'): with description('sclara'): def setup(context): context.foo = 'bar' context.baz = 'baz' with test('does not have access to inner setup context') as context: expect(lambda: context.bar).raises(AttributeError) with test('fails like a normal test'): expect(False) with test('expects dictionary pressence'): expect({'key': 'value'}).contains('key') with test('fails dictionary absence'): expect({'yek': 'value'}).contains('key') with description('during setup'): def setup(context): raise Exception, 'failed setup' with test('fails well'): expect(False)
from sclara import test, description with description('Describing something interesting'): def setup(context): context.foo = 'foo' with test('that has a test at the top level') as context: assert context.foo == 'foo' with test('that fails'): assert False with description('that has bad setup'): def setup(context): raise Exception, 'bad setup' with test('fails'): assert True with description('that has bad teardown'): def teardown(context): raise Exception, 'bad teardown' with test('fails'): assert False with description('that has many levels of interest'): def setup(context): context.bar = 'bar'