Skip to main content

Specification based test runner.

Project description

Speccer provides simple means to test individual modules. It uses a minimal, assert-free syntax. This syntax is compiled to actual code utilizing Python’s unittest. Henceforth Speccer may be seen as an alternative to it in various situations.

Run “setup.py install” to start rocking. See “demo” folder for an actual example. Once you have installed the tool just invoke “run_specs” at that directory. You should see some test results. Feel free to tweak the files to give it a proper go.

Basic Specification Syntax

A module specification could look something like this:

myclass.spec: (tests myclass.py)

set up
    c = myclass.MyClass()

adds two and two
    c.add(2,2) == 4

adds negatives
    c.add(10, -10) == 0

fails adding int and string
    c.add(10, 'foo') raises TypeError

It looks pretty much like any other test you may have seen before. The syntax may be a bit lighter, though. As a test author you can focus on the essential while writing the assertions. In addition it’s a bit nicer to read this way.

Note that it’s possible to mix regular Python code within the tests. This might not work in all cases, though, and should be reported.

“set up” is a predefined test method that is run before each specification. This way you can set up some objects that are available for each test.

Each specification contains a name and some actual code asserting something. I have listed available assertions below:

  • ==, is equal

  • !=, is not equal

  • ~=, is almost equal

  • !~=, is not almost equal

  • >, bigger than

  • >=, bigger than or equal

  • <, smaller than

  • <=, smaller than or equal

  • x < y < z, multiple inequalities (mix with equality as you want)

These assertions map directly to ones available in Python’s unittest module. If some of those seem weird to you, see http://docs.python.org/library/unittest.html .

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

speccer-0.6.0.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file speccer-0.6.0.tar.gz.

File metadata

  • Download URL: speccer-0.6.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for speccer-0.6.0.tar.gz
Algorithm Hash digest
SHA256 22123297f9137b899eeb5cd94ac615fe1e7b2996ac02049626a1848b166751bf
MD5 a4168203ec8d0cd91b562898bc3839ce
BLAKE2b-256 75389817cc37ad2de808453d10aa77cb4d7243a9f6914cbd0b74caec54edd354

See more details on using hashes here.

Supported by

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