PyCon LT 2022

A new framework for testing
2022-05-27 , Python Room

We propose a new method of testing that seems to work really well, but is not formalized in any way. It has been applied in 3 projects of which 2 were serious business (the other is a hackathon project).

No existing testing framework (python or otherwise) embraces this approach, but the core of the idea fits in 50 lines of code.


A generally accepted theory of "testing trophy" states that most of the tests we write should be integration tests. From this we conclude that the mantra "tests should be independent" that makes sense for unit testing, but has been expected from integration tests as well is actually wrong.

The main motivation to have independent tests is to avoid chaos and have a stable repeatable testing environment. We argue that such artificially imposed stability is a source of bugs and a great maintenance burden.

Instead we suggest to make test interdependence explicit and apply the idea that one tests output is the next tests input. For example test_update_user might depend on test_create_user instead of mocking the state of an already created user.


What topics define your talk the best?:

best practices

During school years I participated in mathematics and programming contests with good results.
Then worked as a programmer for 3 years in a blockchain startup (not scam).
Moved to Vilnius and did intensive spiritual practice (Falun Dafa) for one year.
Have been working as a programmer for 1.5 years at ZealiD.
Now I believe technology is harming humans and we should all stop programming.