jneen/parsy — pull request #2 by bugaevc (2014-12-29 20:06:40+00:00)
Title: Testing with unittest

# Problem
Currently the testing code suffers from massive duplication, most noticeably in the form of
```python
try: parser.parse('something'); assert False
except ParseError: pass
```
The other problem is that bare `assert`'s generate useless exception messages.

# Proposed solution
[`unittest`](https://docs.python.org/3/library/unittest) built-in library is the standard way of testing things in Python. It provides the corresponding methods (`.assertEquals()` and `.assertRaises()` in this case) that gracefully solve the problems. The resulting test suite can be run directly as a script, via unittest Test Discovery (executing `python unittest` in the test folder) and via _nose_ as well. This also means that _nose_ can be removed from `requirements.txt` since it's not necessary to run the tests anymore.

**Pros:**
* Standard way of testing
* Pure Python, no external dependencies (namely, no _nose_ dependency)

**Cons:**
* The code is slightly longer and a bit more complicated than equivalent _nose_ code

# Alternative solution
Since the project already has _nose_ as its dependency, it would make sense to use corresponding _nose_ functions (`nose.tools.assert_equals()` and `nose.tools.assert_raises()`).

**Pros:**
* Cleaner and shorter code

# This implementation
Commits below implement the _unittest_ solution.

Aside from that, `letter` and `digit` parsers where moved from `parsy_test.py` to the main module (and reimplemented using built-in `str.isalpha()` and `str.isdigit()` functions) since they're actually useful by themselves (commit 04f804f1e25d48df02ff7e73c616fc16d0ac3e96). It seems like they cover most of `regex()` use cases.