Python testing for humans
Project description
pspec
=====
[![Build Status](https://travis-ci.org/bfirsh/pspec.png?branch=master)](https://travis-ci.org/bfirsh/pspec)
Python testing for humans, built with [Attest](http://packages.python.org/Attest/).
Tests shouldn't just be for computers to check your code runs correctly. They can also be used by humans to understand what your code does.
pspec tests are designed to be parsed by humans. They look a bit like this:
```python
from pspec import describe, assert_raises
import random
with describe('random'):
with describe('shuffle'):
def it_does_not_lose_any_elements():
seq = range(10)
random.shuffle(seq)
seq.sort()
assert seq == range(10)
def it_raises_an_exception_for_an_immutable_sequence():
with assert_raises(TypeError):
random.shuffle((1, 2, 3))
with describe('choice'):
def it_picks_an_element_that_is_in_the_sequence():
seq = range(10)
assert random.choice(seq) in seq
```
(Compare with a [similar example for the built-in unittest module](http://docs.python.org/library/unittest.html#basic-example).)
They are run with the `pspec` command:
$ pspec random_spec
Development install
-------------------
$ pip install -r requirements.txt
$ python setup.py develop
Test suite
----------
$ pspec spec
Goals
-----
**Note:** pspec is still in its infancy. Don't expect it to be useful yet.
Here's some stuff I want it to do:
- Beautiful test reports with coloured string diffs. (Similar to [Mocha's](http://visionmedia.github.com/mocha/#string diffs))
- Contexts, before/after hooks, etc.
It's going to be simple, Pythonic and use minimal magic.
=====
[![Build Status](https://travis-ci.org/bfirsh/pspec.png?branch=master)](https://travis-ci.org/bfirsh/pspec)
Python testing for humans, built with [Attest](http://packages.python.org/Attest/).
Tests shouldn't just be for computers to check your code runs correctly. They can also be used by humans to understand what your code does.
pspec tests are designed to be parsed by humans. They look a bit like this:
```python
from pspec import describe, assert_raises
import random
with describe('random'):
with describe('shuffle'):
def it_does_not_lose_any_elements():
seq = range(10)
random.shuffle(seq)
seq.sort()
assert seq == range(10)
def it_raises_an_exception_for_an_immutable_sequence():
with assert_raises(TypeError):
random.shuffle((1, 2, 3))
with describe('choice'):
def it_picks_an_element_that_is_in_the_sequence():
seq = range(10)
assert random.choice(seq) in seq
```
(Compare with a [similar example for the built-in unittest module](http://docs.python.org/library/unittest.html#basic-example).)
They are run with the `pspec` command:
$ pspec random_spec
Development install
-------------------
$ pip install -r requirements.txt
$ python setup.py develop
Test suite
----------
$ pspec spec
Goals
-----
**Note:** pspec is still in its infancy. Don't expect it to be useful yet.
Here's some stuff I want it to do:
- Beautiful test reports with coloured string diffs. (Similar to [Mocha's](http://visionmedia.github.com/mocha/#string diffs))
- Contexts, before/after hooks, etc.
It's going to be simple, Pythonic and use minimal magic.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pspec-0.0.1.tar.gz
(5.1 kB
view details)
File details
Details for the file pspec-0.0.1.tar.gz
.
File metadata
- Download URL: pspec-0.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aec0a8c9e66b59776f0f89bdead595cb82db08f8c207b047aa2d9ca47181089 |
|
MD5 | e86630471bf9c808aa60702e85f77275 |
|
BLAKE2b-256 | 0eccb7b50eff68e6ef88c1ed57b3bc10b8914a415a0cf985ec6a47a0406918e2 |