myano/jenni — pull request #95 by Venti9874 (2013-06-25 03:01:21+00:00)
Title: Add generation of unit tests from examples

This implements functionality described in issue #292. It makes `@example` inject test-functions into the module, which testing frameworks can then find. I also added a helper function to willie.module that calls pytest with appropriate parameters. The idea is that all modules would have if __name__ == "__main__": willie.module.run_example_tests(__file__) at the bottom.

Right now `@example` with just one parameter works as before, but if you give a second parameter a test is added, where the second parameter is the expected result. If more than one example is given, a test is made for each of them.

Usage requires pytest and pytest-xdist to be installed. I also tested the code coverage plugin pytest-cov and it worked wonderfully.

I added two new classes to bot.Willie: MockWillie and MockWillieWrapper. They are still a bit unfinished. I will add more functionality as needed when converting modules to use this.

I'm adding this as a pull request as I made a bunch of changes and it needs a bit more testing.