benoitbryon/rst2rst — pull request #19 by masklinn (2013-05-15 10:11:03+00:00)
Title: Fixtures tester improvements

Builds on top of #18:
* Removes unimplemented `visit_` and `depart_` methods, on grounds that it's easier to just blow up than have garbage output
* Alters `WriterTestCase` to reify each fixture file as a test case:
- Better overview/progress notifications
- Failure of a fixture does not preclude trying out other fixtures

`WriterTestCase` is 2.6+ (2.5 won't fail but won't find any test case), though most of the complexity comes from remaining compatible with 2.6: Python 2.7 merged unittest2 and introduced [the load_tests protocol](http://docs.python.org/2/library/unittest.html#load-tests-protocol) but in Python 2.6 autodiscovery of dynamic test cases requires:
* overriding `__dir__` so a sequence of `test_$thing` names can be returned to the test loader (on the `TestCase` subclass itself because the test loader calls `dir(testCaseClass)`, thus on a metaclass of the test case)
* overriding `__getattr__` on both the type (because unittest will immediately try to access the name it got on the class itself to check it's callable) and the instance (to provide the actual runner for the corresponding fixture)
* `run_fixture` has the job of actually running the fixture