DEV Community

loading...

Discussion on: Make tests a part of your app

sobolevn profile image
Nikita Sobolev Author

Oh, I see.

The technique you described later on in the article seems to work properly only with pure functions

It reallly depends, because returns expects you to separate pure code from impure. But, when testing laws with IO, it is expected to work with impure code.

This is also the case with deal. It even has its own notation for impure code: deal.readthedocs.io/basic/side-eff...

For both libs you can set your state for impure code before the actual test. So, it should work correctly.

Thread Thread
hanpari profile image
Pavel Morava

The side effects testing (examples with stdin, stdout) is sweet but cannot probably verify whether a user is logged or not. Like I said before, I am not sure if Django is the best candidate for being tested this way. Django testing utilities are better equipped for these tests. The communication with Django views is stateful. This is why I was uncertain how would you test it.

Thread Thread
sobolevn profile image
Nikita Sobolev Author

Take a look at stateful testing in hypothesis and schemathesis:

It might cover some basics on how it can be done!