Testing native binaries using cffi and py.test

Noufal Ibrahim (~nibrahim)




I've been working a native cross platform library to gather system information. The long term intention is to make bindings for it in various languages. The whole thing is written in C and it's somewhat hard to write unit tests for these kinds of libraries.

This talk is about using a combination of cffi and py.test to write unit tests for the library in Python.

The talk will cover some basics of writing python bindings using CFFI and then writing unit tests using these. As a bonus, a small py.test plugin which can be used to measure the unit tests coverage of the C library will be presented.


Basic knowledge of C (and related infrastructure).

Content URLs:

  • https://github.com/nibrahim/cpslib/
  • https://github.com/nibrahim/pytest_gcov

The talk outline is here http://pastebin.com/2u0A2g2x

Speaker Info:

I'm the founder of PyCon India and have been involved with the Indian Python community for quite a while now. I mostly work in infrastructure and automation projects. I'm the founder of the technology services company Hamon

Speaker Links:

  • http://nibrahim.net.in
  • http://github.com/nibrahim
  • http://hamon.in

Section: Testing
Type: Talks
Target Audience: Intermediate
Last Updated: