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.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::