Extending Cookiedozer

Last time we learned how to create a basic Kivy application that will be generated with Cookiecutter. The next logical steps are to add tests and docs. Additionally we will create a setup.py as well as a MAKEFILE.

The template it it’s current state contains the following directories and files:

Set up a TestSuite

There a various ways to manage tests in your app, yet I like to stick to the suggestions at http://pytest.org/latest/goodpractises.html#choosing-a-test-layout-import-rules and keep the tests separated from our application code. By doing so we can easily exclude them from the android package.

Let’s implement a very rudimentary test:

From my experience writing meaningful and yet effective tests for GUIs is not trivial. So I always try my best to strictly separate the business logic from the user interface and have most of the functionality covered by automated tests. In this particular case I’d like to demonstrate how to write tests for a kivy app though.

Actually it took quite a bit of time to figure out how to launch a non-blocking app while still having access to all of it’s attributes. Yet I eventually managed it by using the Interactive Launcher.

As you see I am using a special syntax for my doc strings with respect to the sphinx doc generation, of which more later.

Following the advice of the aforementioned py.test docs , I do not create an  __init__.py inside the tests directory. To run the the suite later on we need to install our package first. Otherwise we are not able to import from any of the application modules.

On the next page of this tutorial we are going to add a setup.py to our template and learn how run the tests.