Nose vs. pytest - what are the (subjective) differences that should make me choose?

I started working on a rather large (multi-threaded) Python project with many (single) tests. The most important issue is that the application requires a predefined environment that is implemented by the context manager. So far, we have used the corrected version of the unit test runner, which ran tests inside this manager, but this does not allow switching context between different test modules.

Both noses and pytest support this kind of thing because they support devices in many details, so we are considering switching to nose or pytest. Both of these libraries will also support tagged tests and run only those flagged subsets that we would also like to do.

I looked through the documentation for both the nose and pytest, and as far as I can see, most of these libraries essentially support the same functions, except that it can be called differently or require slightly different syntax. In addition, I noticed some slight differences in available plugins (nose has multi-processor support, pytest doesn't seem to look)

So the hell seems to be in the details, which means (often at least) personal taste, and we better go with a library that best suits our personal taste.

Therefore, I would ask for subjective reasoning why I should go with my nose or pytest in order to choose the library / community that best suits our needs.

+61
python nose
Apr 04 '14 at 7:45
source share
1 answer

I used Nose because it was the default with Pylons. I didn’t like it at all. It had configuration antennae in several places, almost everything seemed to be done with an underestimated plugin, which made it even more indirect and confusing, and since it performed tests by default, it regularly broke into Unicode traces, hiding the sources of errors.

I have been very pleased with py.test the last couple of years. Being able to write a test using assert out of the box makes me hate writing less tests, and hacking everything I needed on top of the kernel was pretty easy. Instead of the plugin’s fixed interface, it just has heaps of hooks and fairly clear source code if you need to dig further. I even wrote an adapter to run Testify tests under py.test and had more problems with Testify than with py.test.

However, I heard that the nose has plug-ins for classless tests and claim introspection these days, so you are likely to succeed too. I still feel that I can hit the ground while working with py.test, though, and I can understand what happens when it breaks.

+59
Apr 04 '14 at 7:56
source share



All Articles