Skip to main content

An experimental behavioral framework inspired from rspec.

Project description

Describe

An experimental BDD styled framework inspired off of RSpec. The reason of BDD over TDD is out of scope of this article. But this framework is simply a way to try and encourage me to do more testing.

Installation

To install, use pip or easy_install:

pip install describe

Usage

Then you can import the library for use in unittest or nose. Currently there is only one feature, the Value object:

from describe import Value

Use this Value class to wrap values you want to set expectations. Here’s some API examples until I get proper documentation:

# self.assertEquals(9, 9)
Value(9).should == 9

# self.assertAlmostEqual(5.0-4.0, 1.0)
Value(5.0-4.0).should.be_close_to(1.0)

# self.assertIn(3, (2,3,4))
Value((2,3,4)).should.contain(3)

# self.assertNotIn(5, (2,3,4))
Value((2,3,4)).should_not.contain(5)

# self.assertFalse(False)
Value(False).should.be.false()

# self.assertTrue(isinstance((), tuple))
Value(()).should.be.instance_of(tuple)

# self.assertEqual(len(range(5)), 5)
# '.elements' is optional
Value(range(5)).should.have(5).elements

# self.assertGreaterEqual(len(range(5)), 4)
Value(range(5)).should.have.at_least(4)

But this is more code!

Yes, but it’s more readable (your opinion may vary).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

describe-0.1.1.tar.gz (10.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page